在每个给出的子串的起始位置打个标记,记录的是从这里开始的最长子串。

然后输出的时候就扫,如果遇到开始位置,就从这里开始输出,如果其后被更长的覆盖,就跳转到更长的串进行输出。

如果位置没被覆盖,就输出'a'。

#include<cstdio>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
string s[100010];
int n,m,p[2000010],len[100010],nn,now;
void print(int x){
for(int i=x,j=0;j<len[p[x]];++i,++j){
if(!p[i] || i==x || len[p[i]]+j<=len[p[x]]){
putchar(s[p[x]][j]);
now=max(now,i);
}
else{
print(i);
break;
}
}
}
int main(){
int x;
scanf("%d",&n);
for(int i=1;i<=n;++i){
cin>>s[i]>>m;
len[i]=s[i].length();
for(int j=1;j<=m;++j){
scanf("%d",&x);
if(len[i]>len[p[x]]){
p[x]=i;
nn=max(nn,x+len[i]-1);
}
}
}
for(int i=1;i<=nn;){
if(p[i]){
print(i);
i=now+1;
}
else{
putchar('a');
++i;
}
}
puts("");
return 0;
}

【贪心】Codeforces Round #423 (Div. 1, rated, based on VK Cup Finals) A. String Reconstruction的更多相关文章

  1. Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) C. String Reconstruction 并查集

    C. String Reconstruction 题目连接: http://codeforces.com/contest/828/problem/C Description Ivan had stri ...

  2. Codeforces Round #423 (Div. 1, rated, based on VK Cup Finals)

    Codeforces Round #423 (Div. 1, rated, based on VK Cup Finals) A.String Reconstruction B. High Load C ...

  3. Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) E. DNA Evolution 树状数组

    E. DNA Evolution 题目连接: http://codeforces.com/contest/828/problem/E Description Everyone knows that D ...

  4. Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) Problem E (Codeforces 828E) - 分块

    Everyone knows that DNA strands consist of nucleotides. There are four types of nucleotides: "A ...

  5. Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) Problem D (Codeforces 828D) - 贪心

    Arkady needs your help again! This time he decided to build his own high-speed Internet exchange poi ...

  6. Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) D. High Load 构造

    D. High Load 题目连接: http://codeforces.com/contest/828/problem/D Description Arkady needs your help ag ...

  7. Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) A,B,C

    A.题目链接:http://codeforces.com/contest/828/problem/A 解题思路: 直接暴力模拟 #include<bits/stdc++.h> using ...

  8. Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) Problem C (Codeforces 828C) - 链表 - 并查集

    Ivan had string s consisting of small English letters. However, his friend Julia decided to make fun ...

  9. Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) Problem A - B

    Pronlem A In a small restaurant there are a tables for one person and b tables for two persons. It i ...

随机推荐

  1. mave的依赖范围

    compile(编译范围) compile是默认的范围:如果没有提供一个范围,那该依赖的范围就是编译范 围.编译范围依赖在所有的classpath中可用,同时它们也会被打包. provided(已提供 ...

  2. barrier 和 preempt_disable() 学习【转】

    #define preempt_disable() \ do{ \ inc_preempt_count(); \ barrier();    \ }while(0) 一.这个barrier 在干什么. ...

  3. MinnowBoard

    MinnowBoard https://github.com/RafaelRMachado/MinnowBoard https://github.com/RafaelRMachado https:// ...

  4. Timer类

    构造方法:public Timer() 创建一个新计时器.相关的线程不 作为守护程序运行. public Timer(boolean isDaemon) 创建一个新计时器,可以指定其相关的线程作为守护 ...

  5. gradle问题总结与理解(一篇文章带你理解android studio 与gradle 的关系)

    前言:近日在网上找了个很不错的安卓二维码美化,由于下载的项目经常出问题,且不方便依赖使用,因此我想把它写个demo,并把源码发布到jcenter中,修改还是很顺利的,运行项目到手机也没问题,发布遇到了 ...

  6. bzoj 1179 Atm

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1179 题解: 一道比较综合的图论题 直接讲正解: 如果这个图G中存在某个强连通分量,那么这 ...

  7. C基础 寻找随机函数的G点

    引言 随机函数算法应该是计算机史上最重要的十大算法之一吧. 而C中使用的随机函数 #include <stdlib.h> _Check_return_ _ACRTIMP int __cde ...

  8. javascript方法--apply()

    今天琢磨了一下apply,以前对这个方法觉得比较懵,今天一琢磨确实觉得挺好玩的. 一开始把MDN的apply文档看了一遍,感觉不是很理解,而且有一些东西也是知道但是比较模糊,所以还是一步一步来,不懂查 ...

  9. linux命令(13):kill/killall命令

    停止指定的进程名:kill 进程ID号 把所有httpd进程杀掉:killall httpd 强制停止进程mysqld:killall -9 mysqld

  10. 下载安装go插件包报错fatal: unable to access 'https://github.com/golang/tools.git/': OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054

    使用git命令来给vscode安装go插件的时候报错,如下: $ git clone https://github.com/golang/tools.git tools Cloning into 't ...