Codeforces Round #423 (Div. 2) C. String Reconstruction
来源:互联网 发布:淘宝p图教程 编辑:程序博客网 时间:2024/05/29 19:13
题目链接:String Reconstruction
题目大意:有一个字符,但是我们不知道那是什么,现在我们有t个条件,每个条件里面有一个字符串,然后k个起始位置,代表从这个起始位置开始有这样的一个字符串,然后让你求出字典序最小的符合要求的字符串
题目思路:直接暴力当然是不可行的,数据范围是1e6,那么我们可以想到KMP的匹配,重复的不需要去计算,那么我们就不需要去计算了,因为是递增的k个数,所以我们直接保存已经访问到的位置,从这个位置才开始进行数组的赋值就好,这样就会省掉很多的操作,复杂度大概在nsqrtn左右,可过,不过这样暴力的写法确实没想到就会是正解,想了一会没想到更好的办法才上去写的
#include <bits/stdc++.h>using namespace std;const int maxn = 2e6+10;int t,k,s,tot,len,l,st;string str;char ss[maxn];int main(){ std::ios::sync_with_stdio(false); cin>>t; len = 0; while(t--){ cin>>str>>k; l = str.size(); tot = 0; while(k--){ cin>>st; st--; len = max(len,st+l); for(int i = max(st,tot);i < st+l;i++) ss[i] = str[i-st]; tot = st+l; } } for(int i = 0;i < len;i++){ if(ss[i] == '\0') printf("a"); else printf("%c",ss[i]); } puts(""); return 0;}
阅读全文
0 0
- Codeforces Round #423 (Div. 2) C. String Reconstruction(字符串)
- Codeforces Round #423 (Div. 2) C. String Reconstruction
- Codeforces #423-Div. 2-C. String Reconstruction
- Codeforces Round #423 (Div. 2) C. String Reconstruction(思维 模拟)
- Codeforces Round #423 (Div. 2) C String Reconstruction 并查集
- Codeforces Round #423 (Div. 2) C. String Reconstruction思维 D. High Load 构造
- Codeforces Round #423 C. String Reconstruction
- Codeforces Round #423 C. String Reconstruction
- CF Round #423 Div. 2 C. String Reconstruction D. High Load 【思维】
- Codeforces Round #192 (Div. 2) E. Graph Reconstruction (随机算法)
- CodeForces 828C String Reconstruction
- Codeforces 828 C String Reconstruction
- codeforces 828C. String Reconstruction
- Codeforces Round #354 (Div. 2)676C. Vasya and String
- Codeforces Round #354 (Div. 2) C .Vasya and String
- Codeforces Round #354 (Div. 2)-C. Vasya and String
- Codeforces Round #354 (Div. 2) C Vasya and String
- Codeforces Round #354 (Div. 2)C. Vasya and String
- Deepin下安装Oracle Java出现Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=gasp问题解决方案
- N/D to float number
- 隐藏某一个cell的分割线
- PSQL 连接Postgres数据库
- Codeforces 785C Anton and Fairy Tale
- Codeforces Round #423 (Div. 2) C. String Reconstruction
- Git step by step
- 操作系统中读者-写者问题的一点疑问
- maven版本号定义约定
- 51nod 1449 砝码称重(思维+进制)
- POJ 3164 Command Network 笔记
- POJ 2991:Crane
- 程序随笔——timestamp(时间戳)
- RxJava2.0在安卓中的二级缓存策略