#x1006. CF963D Frequency of String
CF963D Frequency of String
Frequency of String
题面翻译
给你一个字符串 ,有 个询问,第 个询问包含一个整数 和一个字符串 。要求找到一个字符串 ,使得 是 的子串并且 至少在 中出现了 次。你只需要求出 的最短长度。
保证 互不相同。
感谢@OrangeLee 提供的翻译
题目描述
You are given a string . You should answer queries. The -th query consists of integer and string . The answer for this query is the minimum length of such a string that is a substring of and has at least occurrences as a substring in .
A substring of a string is a continuous segment of characters of the string.
It is guaranteed that for any two queries the strings from these queries are different.
输入格式
The first line contains string .
The second line contains an integer ( ).
Each of next lines contains an integer and a non-empty string — parameters of the query with number , in this order.
All strings in input consists of lowercase English letters. Sum of length of all strings in input doesn't exceed . All are distinct.
输出格式
For each query output the answer for it in a separate line.
If a string occurs in less that times, output -1.
样例 #1
样例输入 #1
aaaaa
5
3 a
3 aa
2 aaa
3 aaaa
1 aaaaa
样例输出 #1
3
4
4
-1
5
样例 #2
样例输入 #2
abbb
7
4 b
1 ab
3 bb
1 abb
2 bbb
1 a
2 abbb
样例输出 #2
-1
2
-1
3
-1
1
-1