#5591. CSES2108 子串的字典序 I
0
CSES2108 子串的字典序 I
Substring Order I
You are given a string of length n. If all of its distinct substrings are ordered lexicographically, what is the kth smallest of them?
Input
The first input line has a string of length n that consists of characters a–z. The second input line has an integer k.
Output
Print the kth smallest distinct substring in lexicographical order.
Constraints
$It is guaranteed that k does not exceed the number of distinct substrings.$
Example
Input
babaacbaab
10
Output
aba
Explanation: The 10 smallest distinct substrings in order are a, aa, aab, aac, aacb, aacba, aacbaa, aacbaab, ab, and aba.