CF827A.String Reconstruction
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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, k__i. 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.
伊万曾拥有一串由小写英文字母组成的字符串 s。然而,他的朋友朱莉娅决定捉弄他,把字符串 s 隐藏了起来。伊万宁愿重新构造一个新字符串,也不愿费力找回原来的字符串。
伊万还记得关于字符串 s 的一些信息。具体来说,他记得:对于每个字符串 ti,它在 s 中至少出现 ki 次;他还确切地记住了 ti 在 s 中出现的 ki 个位置:这些位置是 xi,1,xi,2,…,xi,ki。他共记住了 n 个这样的字符串 ti。
你的任务是重构出字典序最小的字符串 s,使其满足伊万所记住的所有信息。所有字符串 ti 和字符串 s 均仅由小写英文字母组成。
输入格式
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 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, k__i 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 106, 1 ≤ x__i, j ≤ 106, 1 ≤ k__i ≤ 106, and the sum of all k__i doesn't exceed 106. 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.
第一行包含一个整数 n(1≤n≤105)—— Ivan 记得的字符串个数。
接下来的 n 行描述这些字符串的信息。其中第 i 行包含一个非空字符串 ti,接着是一个正整数 ki,表示字符串 ti 在字符串 s 中出现的次数;然后是 ki 个互不相同的正整数 xi,1,xi,2,…,xi,ki(按升序排列),表示 ti 在 s 中所有出现位置的起始下标。保证所有字符串 ti 的长度之和不超过 106,且对所有 i,j 满足 1≤xi,j≤106,1≤ki≤106,所有 ki 的总和不超过 106。字符串 ti 可以相同。
保证输入数据不自相矛盾,因此至少存在一个合法的答案。
输出格式
Print lexicographically minimal string that fits all the information Ivan remembers.
输出字典序最小的、满足 Ivan 所记住的所有信息的字符串。
输入输出样例
输入#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
输入解题思路,AI测评打分。不知道怎么写?