luogu#P16326. 星降る海
星降る海
Problem Description
You are given a color sequence of length and a positive integer . You may perform the following operation any number of times.
- Choose a subset of and a color , then change the color of every position in to .
Determine the minimum number of operations needed to make the number of maximal color segments exactly , and construct a solution.
If there are multiple possible constructions, you may output any.
Input Format
The first line contains two positive integers .
The second line contains positive integers , denoting the color sequence.
Output Format
Print the minimum number of operations on the first line.
Then print lines describing the operations in order. For each line, the first integer denotes the size of the chosen set, followed by distinct integers between and indicating the elements of the set, and finally an integer between and denoting the new color.
5 3
1 2 3 3 3
0
5 2
1 2 3 3 3
1
1 2 1
5 4
1 2 3 3 3
1
2 4 5 4
Hint
Constraints
For all test cases, and .
| Subtask | Special Property | Score | |
|---|---|---|---|
| None | |||
| A | |||
| B | |||
| None |
- Special Property A: It is guaranteed that .
- Special Property B: It is guaranteed that .