Problem 3031 --Cuber Occurrence

3031: Cuber Occurrence

"
Time Limit $10$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $0$ 正确数量 $0$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
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 tt (1≤t≤1001≤t≤100), indicating there are tt tests. 

The follows tt test cases, Each test consists of two lines. The first line contains a lowercase ascii string ss (1≤|s|≤1051≤|s|≤105 , ∑|s|≤106∑|s|≤106), and the second line is an integer kk (1≤k≤|s|1≤k≤|s|).
For each test case, output a word in one line, which has the Cuber Occurrence of kkin ss. In case there are more than one solutions, output the lexicographically smallest one. If there is no such string, output −1−1 instead.
4
cucucuberqqcucuber
2
cucucuberqqcucuber
5
cucucuberqqcucuber
1
cucucuberqqcucuber
10
b
c
berq
-1

推荐代码 查看3031 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$ $ms]
内存最少[$ $KB]
第一AC
第一挑战

赛题来源/所属竞赛 2019 Multi-University Training Contest 7 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛