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. Redis 命令与连接【十一】

    ---------------------Redis 命令--------------- Redis 命令用于在 redis 服务上执行操作. 要在 redis 服务上执行命令需要一个 redis 客 ...

  2. msp430入门学习12

    msp430的定时器--Timer_A(定时器A) msp430入门学习

  3. P1605 迷宫 洛谷

    https://www.luogu.org/problem/show?pid=1605 题目背景 迷宫 [问题描述] 给定一个N*M方格的迷宫,迷宫里有T处障碍,障碍处不可通过.给定起点坐标和 终点坐 ...

  4. Property 'sqlMapClient' is required

    继承SqlMapClientDaoSupport类的类里面添加如下代码 @Resource(name = "sqlMapClient") private SqlMapClient ...

  5. 007 Vlan config

    sw0(config)#vlan 2 sw0(config-vlan)#name Sales sw0(config-vlan)#vlan 3 sw0(config-vlan)#name Tech sw ...

  6. 在DevExpress GridControl的一列中显示图片

    作者:jiankunking 出处:http://blog.csdn.net/jiankunking 近期做项目的时候用到了将GridControl中一列设置为PictureEdit类型,然后通过这一 ...

  7. c#如何设置成:【当前打开的项目是什么,就默认它为启动项目】,不然新添或打开别的项目都要设置一次启动 [原创]VS2012中将当前选定项目做为启动项

    主菜单→[工具]→[选项]→[项目和解决方案]→[生成并运行],选中“对于新解决方案,使用当前选定的项目作为启动项目” 应该是右键单击解决方案,点击属性打开,选中“当前选定内容”那一项,就可以把你正在 ...

  8. 使用heartbeat+monit实现主备双热备份系统

    一.使用背景 项目须要实现主备双热自己主动切换的功能,保证系统7*24小时不间断执行.现已有两台双网卡的IBM的server,为了不再添加成本採购独立外部存储设备和双机热备软件.採用了linux下开源 ...

  9. 获取Linux磁盘分区的UUID

    在设置fstab自动挂载时,需要填写如下的信息: # <file system> <mount point> <type> <options> < ...

  10. mysql default null empty string concat varchar text

    text不可设置默认值 null  empty string   前者update 初始值时 我响应,但不报错