#P2724. [IOI 1998 / USACO3.1] 联系 Contact
[IOI 1998 / USACO3.1] 联系 Contact
Description
Help the cows by writing a tool that analyzes the records they wrote down in a file to find the truth. They are looking for the bit sequences of lengths between and (inclusive) that occur the top most times in the data file.
Occurrences may overlap, and every sequence that appears at least once should be counted.
Input Format
The first line contains three integers , as defined in the description.
From the second line on is the string , with at most characters per line. Concatenate all lines in order to obtain .
Output Format
Output the most frequent sequences (in order from highest to lowest frequency). For sequences with the same frequency, order them by length from short to long; if the lengths are the same, order by binary value (ascending). If the number of distinct sequences is less than , output all that exist.
For each frequency that occurs, first output a line containing only that frequency, then output the sequences with that frequency, separated by spaces. Print six sequences per line (unless fewer remain).
2 4 10
01010010010001000111101100001010011001111000010010011110010000000
23
00
15
01 10
12
100
11
11 000 001
10
010
8
0100
7
0010 1001
6
111 0000
5
011 110 1000
4
0001 0011 1100
Hint
Explanation for Sample 1
In the sample, the sequence appears times, while the sequence appears times. The most frequent sequence is , which appears times.
Constraints
For of the testdata, it is guaranteed that , , contains only the characters 0 and 1, and the length of is at most .
The problem translation is from NOCOW.
Translated by ChatGPT 5
京公网安备 11011102002149号