比赛 |
名字我取了 |
评测结果 |
AAAAAAAAAAAAAAA |
题目名称 |
字串重组 |
最终得分 |
100 |
用户昵称 |
Ostmbh |
运行时间 |
2.320 s |
代码语言 |
C++ |
内存使用 |
25.49 MiB |
提交时间 |
2017-09-15 21:08:40 |
显示代码纯文本
- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- #include <string>
- using namespace std;
- const int maxn=100000+10;
- struct T{
- int l,r,id;
- bool operator<(const T &a)const{
- if(l==a.l)
- return r-l+1>a.r-a.l+1;
- return l<a.l;
- }
- }A[2000000+10];
- char B[2000000+10];
- string s[maxn];
- int main(){
- freopen("R.in","r",stdin);
- freopen("R.out","w",stdout);
- int n;
- scanf("%d",&n);
- int k,tot=0;
- int x;
- int maxx=0;
- for(int i=1;i<=n;i++){
- cin>>s[i];
- scanf("%d",&k);
- int len=s[i].length();
- for(int j=1;j<=k;j++){
- scanf("%d",&x);
- ++tot;
- A[tot].l=x;
- A[tot].r=x+len-1;
- A[tot].id=i;
- maxx=max(maxx,x+len-1);
- }
- }
- sort(A+1,A+tot+1);
- int now=0;
- int pl=1;
- for(;;){
- while(A[pl].r<=now&&pl!=tot+1)
- pl++;
- if(pl==tot+1)
- break;
- k=max(now,A[pl].l);
- for(int i=k;i<=A[pl].r;i++)
- B[i]=s[A[pl].id][i-A[pl].l];
- now=A[pl].r;
- pl++;
- }
- for(int i=1;i<=maxx;i++)
- if(B[i]>'z'||B[i]<'a')
- printf("a");
- else printf("%c",B[i]);
- return 0;
- }