#P8027. [COCI 2021/2022 #3] Lampice
[COCI 2021/2022 #3] Lampice
Description
Given a string of Christmas lights containing lights, each with a specific color , and an integer .
Now you need to choose a continuous segment of lights from this string. This segment must be divisible evenly from start to end into smaller segments, such that all lights in each smaller segment have the same color.
If there is a valid way to choose such a segment, output the colors of each smaller segment. Otherwise, output .
Input Format
The first line contains two positive integers .
The second line contains positive integers , representing the colors of the Christmas lights.
Output Format
If there is no valid way to choose such a segment, output .
Otherwise, output the length of each smaller segment on the first line, and then output the colors of each smaller segment in order on the next line. If there are multiple valid ways, output any one of them.
8 6
10 1 1 1 1 1 1 5
1
1
3 2
1 2 1
-1
10 2
1 5 1 5 2 5 6 2 5 6
2
1 5
Hint
[Sample 3 Explanation]
Choose the first four Christmas lights or the last six Christmas lights .
[Constraints]
This problem uses bundled subtasks.
- Subtask 1 (10 pts): It is guaranteed that there exist consecutive Christmas lights with the same color.
- Subtask 2 (15 pts): .
- Subtask 3 (25 pts): No special constraints.
For of the testdata, , .
[Hints and Notes]
To handle multiple correct answers, this problem uses a user-written Special Judge. You are welcome to hack.
This problem is translated from COCI 2021-2022 CONTEST #3 Task 1 Lampice.
The score of this problem follows the original COCI setting, with a full score of .
Translated by ChatGPT 5
京公网安备 11011102002149号