#P8330. [ZJOI2022] 众数
[ZJOI2022] 众数
Problem Description
Kurenai Kujou is a pitiful girl with superpowers, but her superpower can only be used on some strange things.
One day, Kurenai got a sequence . She can use her superpower on this sequence once: choose an interval () and an integer , and add to all numbers in the interval.
Kurenai likes sequences that look as consistent as possible, so she wants the final sequence to have the mode occur as many times as possible. Given the sequence , you need to output the maximum possible number of occurrences of the mode in the final sequence, and output all possible values of this mode. Note that for a sequence, the mode may have more than one value.
Input Format
The input contains multiple test cases. The first line contains the number of test cases .
For each test case, the first line contains the sequence length , and the second line contains integers .
Output Format
For each test case, output the maximum possible number of occurrences of the mode in the final sequence on the first line.
Suppose this mode has different possible values. Then output these values in increasing order, one per line, for a total of lines.
4
5
1 2 3 2 1
5
1 1 3 1 1
6
2 4 2 4 8 8
5
1 2 3 4 5
4
1
5
1
4
2
4
8
2
1
2
3
4
5
见附件中的 mode/mode_ex2.in
见附件中的 mode/mode_ex2.ans
Hint
For all testdata: , , , it is guaranteed that , and the are not all equal.
The specific limits for each test point are shown in the table below:
| Test Point ID | Special Constraint | ||
|---|---|---|---|
| None | |||
| has only distinct values | |||
| None | |||
Translated by ChatGPT 5