#P8027. [COCI 2021/2022 #3] Lampice

[COCI 2021/2022 #3] Lampice

Description

Given a string of Christmas lights containing nn lights, each with a specific color aia_i, and an integer kk.

Now you need to choose a continuous segment of lights from this string. This segment must be divisible evenly from start to end into kk 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 1-1.

Input Format

The first line contains two positive integers n,kn, k.

The second line contains nn positive integers aia_i, representing the colors of the Christmas lights.

Output Format

If there is no valid way to choose such a segment, output 1-1.

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 1,5;1,51,5;1,5 or the last six Christmas lights 2,5,6;2,5,62,5,6;2,5,6.

[Constraints]

This problem uses bundled subtasks.

  • Subtask 1 (10 pts): It is guaranteed that there exist kk consecutive Christmas lights with the same color.
  • Subtask 2 (15 pts): k=2k = 2.
  • Subtask 3 (25 pts): No special constraints.

For 100%100\% of the testdata, 1kn501 \le k \le n \le 50, 1ai10001 \le a_i \le 1000.

[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 5050.

Translated by ChatGPT 5