String Reconstruction CodeForces
来源:互联网 发布:c语言合法标识符有哪些 编辑:程序博客网 时间:2024/06/05 03:10
在下还是太弱了
#include <cstdio>#include <cstring>#include <algorithm>#include <iostream>#include <string>#include <vector>#include <stack>#include <bitset>#include <cstdlib>#include <cmath>#include <set>#include <list>#include <deque>#include <map>#include <queue>using namespace std;typedef long long ll;#define maxn 1000010char s[maxn];int ans[maxn];char anss[maxn];struct node{ int l; int r; int ix;}dic[maxn];bool cmp (node a,node b){ if (a.l==b.l ){ return a.r > b.r; } return a.l < b.l;}vector <int> g[maxn];int main (){ int n; int i; int t= 0; scanf ("%d",&n); for (i=1;i<=n;i++){ scanf("%s",s); int j; int ll =strlen (s); for (j=0;j<strlen(s);j++){ g[i].push_back (s[j]-'a'); } int d; scanf ("%d",&d); for (j=1;j<=d;j++){ int a; scanf ("%d",&a); dic[++t].l = a; dic[t].r = a + ll-1; dic[t].ix = i; } } //for (i=1;i<=t;i++){// for (int j=0;j<g[i].size();j++) // printf("%d",g[i][j]); // printf("\n"); //} sort (dic+1,dic+1+t,cmp); //for (i=1;i<=t;i++){// printf("%d %d %d\n",dic[i].l,dic[i].r,dic[i].ix); // } int tmp = 0; int j; int right = 0; for (i=1;i<=t;i++){ int left = dic[i].l; int d = dic[i].ix; if (dic[i].r >tmp){ right = max (right,dic[i].r); int begin = left; if (left >tmp){ for (j=0;j<g[d].size();j++){ ans[begin++] = g[d][j];// printf("%d",ans[begin-1]); } } else { int begin = tmp+1; int le = tmp+1-left; for (j= le;j<g[d].size();j++){ ans[begin++]=g[d][j]; } } tmp = dic[i].r; } } //puts (""); for (i=1;i<=right;i++){ if (!ans[i]) printf("a"); else{ printf("%c",ans[i]+'a'); } } printf("\n");}
阅读全文
0 0
- String Reconstruction CodeForces
- CodeForces 828C String Reconstruction
- Codeforces 827A. String Reconstruction
- Codeforces 828 C String Reconstruction
- codeforces 828C. String Reconstruction
- Codeforces #423-Div. 2-C. String Reconstruction
- Codeforces Round #423 C. String Reconstruction
- Codeforces 828 C. String Reconstruction 思维
- CodeForces 828C String Reconstruction(思维)
- Codeforces Round #423 C. String Reconstruction
- codeforces 828 c String Reconstruction(扫描线+string)
- Codeforces Round #423 (Div. 2) C. String Reconstruction(字符串)
- Codeforces Round #423 (Div. 2) C. String Reconstruction
- Codeforces 828C String Reconstruction【思维+并查集】
- Codeforces #848C: String Reconstruction 题解之花样虐题
- Codeforces828 C. String Reconstruction
- Codeforces828 C. String Reconstruction
- Codeforces Round #423 (Div. 2) C. String Reconstruction(思维 模拟)
- STM32的串口采用DMA方式接收数据测试
- newoj墓地2908: 素数环PrimeRing 深搜
- 本机链接kafka超时
- Java数组&排序作业
- Python 安装 face recognition
- String Reconstruction CodeForces
- softmax分类
- bounding box voting
- 如何解决百万级数据查询优化
- UVA10375唯一分解定理
- Apache服务器下载安装启动
- Spring Boot
- 搭建storybook--es6+react+less
- meta