C. String Reconstruction
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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.

Output

Print lexicographically minimal string that fits all the information Ivan remembers.

Examples
input
3
a 4 1 3 5 7
ab 2 1 5
ca 1 4
output
abacaba
input
1
a 1 3
output
aaa

官方题解:

一开始sort排序,然后依次按顺序放入字符串

直接看代码(注意,输入需改为scanf格式,否则会超时)

#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的更多相关文章

  1. Codefoces 432C Prime Swaps(数论+贪心)

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/u011328934/article/details/26094917 题目连接:Codefoces ...

  2. 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 ...

  3. codefoces round193a

    link: http://codeforces.com/contest/332/problem/A /* ID: zypz4571 LANG: C++ TASK: 193a.cpp */ #inclu ...

  4. Codefoces 429 D. Tricky Function

    裸的近期点对.... D. Tricky Function time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  5. Codefoces 432 C. Prime Swaps

    哥德巴赫猜想: 任一大于2的偶数,都可表示成两个素数之和. 任一大于5的整数都可写成三个质数之和. 贪心取尽可能大的素数..... C. Prime Swaps time limit per test ...

  6. Codefoces 723B Text Document Analysis

    B. Text Document Analysis time limit per test:1 second memory limit per test:256 megabytes input:sta ...

  7. 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 ...

  8. Codefoces Gym 101652 【最大连续和】

    <题目链接> 题目大意: 给你一段只由 'B'和'R'组成的字符串,问你在连续的区间内,"B"和"R"的差值最大是多少,输出该区间:如果对于差值相等 ...

  9. Codefoces 277 E. Binary Tree on Plane

    题目链接:http://codeforces.com/problemset/problem/277/E 参考了这篇题解:http://blog.csdn.net/Sakai_Masato/articl ...

随机推荐

  1. js重新讲解继承,es5的一些继承,es6继承的改变 ----------由浅入深

    es5 利用原型公有私有继承 function Parent(name) { this.name = name } Parent.prototype.home = '北京'; function Chi ...

  2. 18.10.7 POIN 模拟赛

    期望 :80+ +90+40=210+ 实际 :30+90+0=120 链接:https://www.nowcoder.com/acm/contest/175/A来源:牛客网 时间限制:C/C++ 1 ...

  3. 我的arcgis培训照片13

    来自:http://www.cioiot.com/successview-535-1.html

  4. 我的arcgis培训照片8

    来自:http://www.cioiot.com/successview-554-1.html

  5. java.util.Scanner

    java.util.Scanner是Java5的新特征,主要功能是简化文本扫描.这个类最实用的地方表现在获取控制台输入,其他的功能都很鸡肋,尽管Java API文档中列举了大量的API方法,但是都不怎 ...

  6. TP-Link的Atheros芯片的WR886n v5 安装SuperWRT系统

    安装SuperWRT系统 本教程以TP-Link的Atheros芯片的WR886n v5为例,教新手如何刷入一个已支持设备的固件. 下载设备固件请访问:这里 (没有支持你的设备?自由动手一下:hack ...

  7. windows 7 忘記密碼,用“带命令行的安全模式”

    net user administrator /active:yes net user tester /add net localgroup administrators tester /add

  8. 86. LotusScript中的数组函数

    R6对LotusScript有一些改进和增强,自那之后.Notes对象的接口时有补充和更新,但语言本身没有变化.那些改进就包括添加诸如ArrayGetIndex.ArrayUnique的实用函数. 但 ...

  9. java UDP聊天与文件传输

    package rgy.com.UDP3; import java.awt.Font; import java.awt.GridLayout; import java.awt.event.Action ...

  10. HDU 1018 Big Number (log函数求数的位数)

    Problem Description In many applications very large integers numbers are required. Some of these app ...