#P2724. [IOI 1998 / USACO3.1] 联系 Contact

    ID: 1732 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>USACO枚举,暴力排序概率论,统计

[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 AA and BB (inclusive) that occur the top nn 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 A,B,nA, B, n, as defined in the description.

From the second line on is the string ss, with at most 8080 characters per line. Concatenate all lines in order to obtain ss.

Output Format

Output the nn 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 nn, 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 100100 appears 1212 times, while the sequence 10001000 appears 55 times. The most frequent sequence is 0000, which appears 2323 times.


Constraints

For 100%100\% of the testdata, it is guaranteed that 1n501 \leq n \leq 50, 1AB121 \leq A \leq B \leq 12, ss contains only the characters 0 and 1, and the length of ss is at most 2×1052 \times 10^5.


The problem translation is from NOCOW.

Translated by ChatGPT 5