Codefoces 828C
2 seconds
256 megabytes
standard input
standard output
Ivan had string s consisting of small English letters. However, his friend Julia decided to make fun of him and hid the string s.
Ivan preferred making a new string to finding the old one.
Ivan knows some information about the string s. Namely, he remembers, that string ti occurs
in string s at least ki times
or more, he also remembers exactly ki positions
where the string ti occurs
in string s: these positions are xi, 1, xi, 2, ..., xi, ki.
He remembers n such strings ti.
You are to reconstruct lexicographically minimal string s such that
it fits all the information Ivan remembers. Strings ti and
string s consist of small English letters only.
The first line contains single integer n (1 ≤ n ≤ 105)
— the number of strings Ivan remembers.
The next n lines contain information about the strings. The i-th
of these lines contains non-empty string ti,
then positive integer ki,
which equal to the number of times the string ti occurs
in string s, and then ki distinct
positive integers xi, 1, xi, 2, ..., xi, ki in
increasing order — positions, in which occurrences of the string ti in
the string s start. It is guaranteed that the sum of lengths of strings ti doesn't
exceed 106, 1 ≤ xi, j ≤ 106, 1 ≤ ki ≤ 106,
and the sum of all ki doesn't
exceed 106.
The strings ti can
coincide.
It is guaranteed that the input data is not self-contradictory, and thus at least one answer always exists.
Print lexicographically minimal string that fits all the information Ivan remembers.
3
a 4 1 3 5 7
ab 2 1 5
ca 1 4
abacaba
1
a 1 3
aaa
官方题解:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<string.h>
#include<stdio.h>
using namespace std;
const int maxn=1e6+100;
string s[maxn];
vector<pair<int ,int> >tmp;
int main()
{
int n,k,x;
scanf("%d",&n);
for(int i=0;i<n;i++){
cin>>s[i]>>k;
for(int j=0;j<k;j++)
{
scanf("%d",&x);
tmp.push_back(make_pair(x,i));
}
}
sort(tmp.begin(),tmp.end());
string ans;
int len=1;
for(int i=0;i<tmp.size();i++)
{
int t1=tmp[i].first,t2=tmp[i].second;
while(t1>len)
{
ans+='a';
len++;
}//len-t1可以避免重复添加
for(int j=len-t1;j<s[t2].length();j++)
{
ans+=s[t2][j];
len++;
}
}
cout<<ans<<endl;
return 0;
}
Codefoces 828C的更多相关文章
- Codefoces 432C Prime Swaps(数论+贪心)
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/u011328934/article/details/26094917 题目连接:Codefoces ...
- 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 ...
- codefoces round193a
link: http://codeforces.com/contest/332/problem/A /* ID: zypz4571 LANG: C++ TASK: 193a.cpp */ #inclu ...
- Codefoces 429 D. Tricky Function
裸的近期点对.... D. Tricky Function time limit per test 2 seconds memory limit per test 256 megabytes inpu ...
- Codefoces 432 C. Prime Swaps
哥德巴赫猜想: 任一大于2的偶数,都可表示成两个素数之和. 任一大于5的整数都可写成三个质数之和. 贪心取尽可能大的素数..... C. Prime Swaps time limit per test ...
- Codefoces 723B Text Document Analysis
B. Text Document Analysis time limit per test:1 second memory limit per test:256 megabytes input:sta ...
- Codefoces 723A The New Year: Meeting Friends
A. The New Year: Meeting Friends time limit per test:1 second memory limit per test:256 megabytes in ...
- Codefoces Gym 101652 【最大连续和】
<题目链接> 题目大意: 给你一段只由 'B'和'R'组成的字符串,问你在连续的区间内,"B"和"R"的差值最大是多少,输出该区间:如果对于差值相等 ...
- Codefoces 277 E. Binary Tree on Plane
题目链接:http://codeforces.com/problemset/problem/277/E 参考了这篇题解:http://blog.csdn.net/Sakai_Masato/articl ...
随机推荐
- 剑客决斗(NYOJ 110)
T3.题目110剑客决斗 (http://acm.nyist.net/JudgeOnline/problem.php?pid=110) 描述 在路易十三和红衣主教黎塞留当权的时代,发生了一场决斗.n个 ...
- readdir() 获取文件类型
readdir()获取文件类型 //// 字符设备文件 type =2, filename207=tty0 crw-rw---- 1 root root 4, 0 04-10 16:28 ...
- Educational Codeforces Round 45 (Rated for Div. 2) C、D
C. Bracket Sequences Concatenation Problem time limit per test 2 seconds memory limit per test 256 ...
- Gym100812 L 扩展欧几里得
L. Knights without Fear and Reproach time limit per test 2.0 s memory limit per test 256 MB input st ...
- 《Java设计模式》之状态模式
状态模式,又称状态对象模式(Pattern of Objects for States),状态模式是对象的行为模式. 状态模式同意一个对象在其内部状态改变的时候改变其行为.这个对象看上去就像是改变了它 ...
- vue 重要的东西
- Flink内存管理源代码解读之基础数据结构
概述 在分布式实时计算领域,怎样让框架/引擎足够高效地在内存中存取.处理海量数据是一个非常棘手的问题.在应对这一问题上Flink无疑是做得非常杰出的,Flink的自主内存管理设计或许比它自身的知名度更 ...
- 解决Vue打包后背景图片路径错误问题
1.原因解析 当用vue-cli自动构建项目后,有两种运行方法,分别是: npm run dev : 提供一个开发的环境,自动热更新,资源使用绝对路径,所以可以正常看到背景图片. npm run bu ...
- Vijos P1023Victoria的舞会3【贪心+DFS求强联通分量】
链接:Click Me! P1023Victoria的舞会3 Accepted 标签:Victoria的舞会[显示标签] 描写叙述 Victoria是一位颇有成就的艺术家,他因油画作品<我爱北京 ...
- 解决ubuntu中firefox浏览器总是提示找不到server的问题
这个情况在我机器上常常出现,并且时不时的给你出点问题.可是有些时候等一下就好了.或者把引擎换到百度的话它就又行得通了.. 被这个问题搞得非常烦.上网查了下说是防火墙啊之类的出问题.可是自己弄了后这个问 ...