Time limit
2s
Memory limit
16 MB
You are given a DNA sequence S of length n. The sequence is a string made of the letters A, C, G, and T.
In this problem, a partial DNA sequence means a string obtained by taking one contiguous interval of S. For example, the partial DNA sequences of AGCT include AG, GC, AGC, and AGCT. AC is not a partial DNA sequence because C does not appear immediately after A.
Among all distinct partial DNA sequences, consider only those that appear in S at least m times. For example, in AGAG, A, G, and AG each appear at least twice.
Find the total number of partial DNA sequences that satisfy this condition, and find the K-th one after sorting them. Shorter strings come first; strings of the same length are ordered lexicographically.
The first line contains three integers n, m, and K.
The second line contains the DNA sequence S of length n.
K does not exceed the number of partial DNA sequences that satisfy the condition.
Print the number of distinct partial DNA sequences that appear at least m times on the first line.
Print the K-th partial DNA sequence in the sorted order on the second line.
For reference, when m=4 for the provided input, the qualifying partial DNA sequences are A, C, G, T, GG, AT, AG, GA, TC, CG, ATC, TCG, and ATCG. This list is not sorted.