题目描述
Problem Description
Given a sequence of $n$ Christmas lights with specific colors $a_i$ and an integer $k$.
You need to select a continuous segment of these lights such that it can be exactly divided into $k$ subsegments, each with the same color.
If there is a valid selection, output the color of each subsegment; otherwise, output $-1$.
Input Format
The first line contains two positive integers $n$ and $k$.
The second line contains $n$ positive integers $a_i$, representing the colors of the Christmas lights.
Output Format
If there is no valid selection, output $-1$.
Otherwise, output the length of each subsegment in the first line, and the colors of each subsegment in the second line in order. If there are multiple valid selections, output any one of them.
Sample Input and Output
Sample Input #1
8 6
10 1 1 1 1 1 1 5
Sample Output #1
1
1
Sample Input #2
3 2
1 2 1
Sample Output #2
-1
Sample Input #3
10 2
1 5 1 5 2 5 6 2 5 6
Sample Output #3
2
1 5
Notes
Explanation for Sample 3
Select the first four lights $1,5;1,5$ or the last six lights $2,5,6;2,5,6$.
Data Range and Constraints
This problem uses subtask-based testing.
- Subtask 1 (10 pts): Guaranteed to have $k$ consecutive lights of the same color.
- Subtask 2 (15 pts): $k=2$.
- Subtask 3 (25 pts): No special restrictions.
For $100\%$ of the data, $1 \le k \le n \le 50$, $1 \le a_i \le 1000$.
Hints and Notes
To handle multiple solutions, this problem uses a custom Special Judge. Feel free to hack.
This problem is translated from COCI 2021-2022 CONTEST #3 Task 1 Lampice.
The score is set according to the original COCI problem, with a maximum of $50$ points.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分