#P3975. [TJOI2015] 弦论

    ID: 2906 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2015各省省选后缀自动机,SAM枚举,暴力后缀数组,SA天津

[TJOI2015] 弦论

Description

To boost her IQ, ZJY started studying string theory. One day, she saw the following problem in "String theory": Given a string of length nn, find its kk-th smallest substring. Can you help her?

Input Format

The first line contains a string ss consisting only of lowercase English letters.

The second line contains two integers tt and kk. If t=0t = 0, identical substrings at different positions are counted as one; if t=1t = 1, identical substrings at different positions are counted multiple times. The meaning of kk is as described above.

Output Format

Output exactly one line containing a string, which is the kk-th smallest substring. If there are fewer than kk substrings, output -1.

aabc
0 3
aab
aabc
1 3
aa
aabc
1 11
-1

Hint

Constraints

For 10%10\% of the testdata, n1000n\leq 1000.

For 50%50\% of the testdata, t=0t = 0.

For 100%100\% of the testdata, 1n5×1051\leq n \leq 5 \times 10^5, 0t10\leq t \leq 1, 1k1091\leq k \leq 10^9.

Translated by ChatGPT 5