当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6648:Cuber Occurrence

题目描述
Recently, Cuber QQ has received a letter from his old friend Little Fang, which is a strangely long paper note. Cuber QQ thought it will be interesting to count the occurrences of some words in this paper note, thus he brought in a dictionary. If you are curious about what occurrences mean, here are some examples: "nan" appears once in "banana"; "a" appears 3 times in "banana", "ana" appears twice in "banana".

When Cuber QQ got up the second day, he forgot all about his counting yesterday, and he figured he had to do that again. So he used a highlight pen and highlighted those occurrences. Note that a letter can't be highlighted more than once. For example, finding "ana" in "banana" will result in highlighting altogether 5 letters.

On the third day, Cuber QQ again noticed a problem he could have noticed on the second day. He can't tell the number of occurrences from his highlighting because of some touching or overlapping area. If you are counting "a" in "banana", you will get 3; that's fine. Counting "an" or "ana" will all give you the wrong count, which is 1. Cuber QQ has finally given up and named his incorrect counting as Cuber Occurrence.

Let's do a more complicated example to make sure everything is clear. Cuber Occurrence of "cuc" in "cucucuberqqcucuber" is 2, and that of "q" is 1 (since two "q" are touching each other), and that of "u" is 5.

Cuber QQ couldn't help wondering the opposite problem. If he knows the Cuber Occurrence of a word in a string, could you find him this word?
输入解释
The first line of the input contains an integer $t$ ($1 \le t \le 100$), indicating there are $t$ tests.

The follows $t$ test cases, Each test consists of two lines. The first line contains a lowercase ascii string $s$ ($1 \le |s| \le 10^5$ , $\sum |s|\le 10^6$), and the second line is an integer $k$ ($1 \le k \le |s|$).
输出解释
For each test case, output a word in one line, which has the Cuber Occurrence of $k$ in $s$. In case there are more than one solutions, output the lexicographically smallest one. If there is no such string, output $-1$ instead.
输入样例
4
cucucuberqqcucuber
2
cucucuberqqcucuber
5
cucucuberqqcucuber
1
cucucuberqqcucuber
10
输出样例
b
c
berq
-1

提示
Special note if you are doing this problem on HDOJ: The memory limit can be a little tight as 512MB is the best we can do.
来自杭电HDUOJ的附加信息
Recommend chendu

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6648

最后修改于 2020-10-25T23:33:08+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
20000/10000MS(Java/Others) 524288/524288K(Java/Others)