比赛 名字我取了 评测结果 AAAAAAAAAAAAAAA
题目名称 字串重组 最终得分 100
用户昵称 Ostmbh 运行时间 2.320 s
代码语言 C++ 内存使用 25.49 MiB
提交时间 2017-09-15 21:08:40
显示代码纯文本
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. #include <string>
  5. using namespace std;
  6. const int maxn=100000+10;
  7. struct T{
  8. int l,r,id;
  9. bool operator<(const T &a)const{
  10. if(l==a.l)
  11. return r-l+1>a.r-a.l+1;
  12. return l<a.l;
  13. }
  14. }A[2000000+10];
  15. char B[2000000+10];
  16. string s[maxn];
  17. int main(){
  18. freopen("R.in","r",stdin);
  19. freopen("R.out","w",stdout);
  20. int n;
  21. scanf("%d",&n);
  22. int k,tot=0;
  23. int x;
  24. int maxx=0;
  25. for(int i=1;i<=n;i++){
  26. cin>>s[i];
  27. scanf("%d",&k);
  28. int len=s[i].length();
  29. for(int j=1;j<=k;j++){
  30. scanf("%d",&x);
  31. ++tot;
  32. A[tot].l=x;
  33. A[tot].r=x+len-1;
  34. A[tot].id=i;
  35. maxx=max(maxx,x+len-1);
  36. }
  37. }
  38. sort(A+1,A+tot+1);
  39. int now=0;
  40. int pl=1;
  41. for(;;){
  42. while(A[pl].r<=now&&pl!=tot+1)
  43. pl++;
  44. if(pl==tot+1)
  45. break;
  46. k=max(now,A[pl].l);
  47. for(int i=k;i<=A[pl].r;i++)
  48. B[i]=s[A[pl].id][i-A[pl].l];
  49. now=A[pl].r;
  50. pl++;
  51. }
  52. for(int i=1;i<=maxx;i++)
  53. if(B[i]>'z'||B[i]<'a')
  54. printf("a");
  55. else printf("%c",B[i]);
  56. return 0;
  57. }