z-SubLexico
Given a string S and Q queries which contain only a single integer K, write the K-th lexicographical smallest distinct substring.
Two substring A and B are defined as distinct if:
- their lengths are different
- their lengths are equal and A and B differ in at least one letter.
Example:
S = "aaa"
substrings of S are "a" , "a" , "a" , "aa" , "aa" , "aaa" ,
and the distinct substrings are "a" , "aa" , "aaa" .
That means that in "aaa" the first disctinct substring is "a" , second "aa", and
third "aaa".
Additional info:
- answer will always exist
Input:
Output:
Two substring A and B are defined as distinct if:
- their lengths are different
- their lengths are equal and A and B differ in at least one letter.
Example:
S = "aaa"
substrings of S are "a" , "a" , "a" , "aa" , "aa" , "aaa" ,
and the distinct substrings are "a" , "aa" , "aaa" .
That means that in "aaa" the first disctinct substring is "a" , second "aa", and
third "aaa".
InputIn the first line there is string S (with length no more than 90000 characters). It contains only small letters of English alphabet. The second line contains a single integer Q
( Q<=500 ) , the number of queries. In the next Q lines a single integer K is given
(K < 2^31).
( Q<=500 ) , the number of queries. In the next Q lines a single integer K is given
(K < 2^31).
OutputWrite Q lines which will contain the answers for the corresponding queries.
i-th line in the output must answer the i-th query in input.
i-th line in the output must answer the i-th query in input.
Additional info:
- answer will always exist
Input:
aaa
2
2
3
Output:
aa
aaaSubmit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.