Codeforces 828 C String Reconstruction
来源:互联网 发布:java个人信息管理系统 编辑:程序博客网 时间:2024/05/16 06:22
题目地址:http://codeforces.com/contest/828/problem/C
题意:给你一些字符串的提示,让你拼接出一个完整的字典序最小的字符串(PS:是一定会有字符串的,所以重复的可以不用去看,因为一定是对的,我就是一开始没看懂这个TLE了)
思路:把起点的顺序排序,再遍历。重复的就不用考虑,详细看代码,比较容易理解,仔细点就好了
#include <iostream>#include <cstring>#include <string>#include <queue>#include <vector>#include <map>#include <set>#include <stack>#include <cmath>#include <cstdio>#include <algorithm>#define LL long long #define N 10000010#define M 50010#define inf 0x3f3f3f3fusing namespace std;const LL mod = 1e9 + 7;const double eps = 1e-9;string str[N];struct node { int id, x;}now;vector<node>v;bool cmp(node a, node b) { if (a.x == b.x) { return str[a.id].length() > str[b.id].length(); } return a.x < b.x;}int main() { cin.sync_with_stdio(false); int n, m; while (cin >> n) { v.clear(); for (int i = 0; i < n; i++) { cin >> str[i] >> m; now.id = i; for (int j = 0; j < m; j++) { cin >> now.x; v.push_back(now); } } sort(v.begin(), v.end(), cmp); int len = v.size(); int num = 1; for (int i = 0; i < len; i++) { while (num < v[i].x) { num++; cout << "a"; } if (num != v[i].x) { if (num > v[i].x + str[v[i].id].length()) { continue; } for (int j = num - v[i].x; j < str[v[i].id].length(); j++) { cout << str[v[i].id][j]; num++; } } else { cout << str[v[i].id]; num += str[v[i].id].length(); } } cout << endl; } return 0;}
阅读全文
0 0
- CodeForces 828C String Reconstruction
- Codeforces 828 C String Reconstruction
- codeforces 828C. String Reconstruction
- Codeforces 828 C. String Reconstruction 思维
- CodeForces 828C String Reconstruction(思维)
- codeforces 828 c String Reconstruction(扫描线+string)
- Codeforces 828C String Reconstruction【思维+并查集】
- Codeforces #423-Div. 2-C. String Reconstruction
- Codeforces Round #423 C. String Reconstruction
- Codeforces Round #423 C. String Reconstruction
- String Reconstruction CodeForces
- Codeforces 827A/828C String Reconstruction[线段树单点更新]
- Codeforces Round #423 (Div. 2) C. String Reconstruction(字符串)
- Codeforces Round #423 (Div. 2) C. String Reconstruction
- Codeforces #848C: String Reconstruction 题解之花样虐题
- CF 828C String Reconstruction(暴力)
- Codeforces828 C. String Reconstruction
- Codeforces828 C. String Reconstruction
- 秒懂!何凯明的深度残差网络PPT是这样的|ICML2016 tutorial
- 【软件安全】cwe-89 SQL Injection(二)
- jquery 插件开发/插件编写$.fn.extend(),$.extend()
- @Embedded和@Embeddable
- TCP报文段首部分析详解
- Codeforces 828 C String Reconstruction
- c/c++整理--重载运算符
- Javaweb记录日志到数据库和文件中
- 014 Python语法之文件与异常
- openGL 3D图形和openGL简介
- Eclipse安装svn插件的几种方式
- 小M开发_JS_day0713
- 协程的实现原理
- 类方法和对象方法的区别