A10983 | String Reconstruction
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $t_{i}$ occurs in string $s$ at least $k_{i}$ times or more, he also remembers exactly $k_{i}$ positions where the string $t_{i}$ occurs in string $s$ : these positions are $x_{i,1},x_{i,2},...,x_{i,ki}$ . He remembers $n$ such strings $t_{i}$ .
You are to reconstruct lexicographically minimal string $s$ such that it fits all the information Ivan remembers. Strings $t_{i}$ and string $s$ consist of small English letters only.
Ivan knows some information about the string $s$ . Namely, he remembers, that string $t_{i}$ occurs in string $s$ at least $k_{i}$ times or more, he also remembers exactly $k_{i}$ positions where the string $t_{i}$ occurs in string $s$ : these positions are $x_{i,1},x_{i,2},...,x_{i,ki}$ . He remembers $n$ such strings $t_{i}$ .
You are to reconstruct lexicographically minimal string $s$ such that it fits all the information Ivan remembers. Strings $t_{i}$ and string $s$ consist of small English letters only.
输入格式
The first line contains single integer $n$ ( $1<=n<=10^{5}$ ) — 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 $t_{i}$ , then positive integer $k_{i}$ , which equal to the number of times the string $t_{i}$ occurs in string $s$ , and then $k_{i}$ distinct positive integers $x_{i,1},x_{i,2},...,x_{i,ki}$ in increasing order — positions, in which occurrences of the string $t_{i}$ in the string $s$ start. It is guaranteed that the sum of lengths of strings $t_{i}$ doesn't exceed $10^{6}$ , $1<=x_{i,j}<=10^{6}$ , $1<=k_{i}<=10^{6}$ , and the sum of all $k_{i}$ doesn't exceed $10^{6}$ . The strings $t_{i}$ can coincide.
It is guaranteed that the input data is not self-contradictory, and thus at least one answer always exists.
The next $n$ lines contain information about the strings. The $i$ -th of these lines contains non-empty string $t_{i}$ , then positive integer $k_{i}$ , which equal to the number of times the string $t_{i}$ occurs in string $s$ , and then $k_{i}$ distinct positive integers $x_{i,1},x_{i,2},...,x_{i,ki}$ in increasing order — positions, in which occurrences of the string $t_{i}$ in the string $s$ start. It is guaranteed that the sum of lengths of strings $t_{i}$ doesn't exceed $10^{6}$ , $1<=x_{i,j}<=10^{6}$ , $1<=k_{i}<=10^{6}$ , and the sum of all $k_{i}$ doesn't exceed $10^{6}$ . The strings $t_{i}$ 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.
输入输出样例
输入 #1
3 a 4 1 3 5 7 ab 2 1 5 ca 1 4
输出 #1
abacaba
输入 #2
1 a 1 3
输出 #2
aaa
输入 #3
3 ab 1 1 aba 1 3 ab 2 3 5
输出 #3
ababab
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted