#P10854. 【MX-X2-T3】「Cfz Round 4」Ninelie
【MX-X2-T3】「Cfz Round 4」Ninelie
Background
Original problem link: https://oier.team/problems/X2C。

Along the one-sided endless echoing melody, it flows through the streets before my eyes, together with a love that has come to an end, fading farther and farther away.
That ideal blueprint that cannot be conveyed grows more and more twisted; the silent resistance awakens at this very moment, and the impulse also arrives late at this very moment.
Broken cries and beautiful dreams; the ideal is left with only a decorative facade.
Even if the city is willing to be drowned in noise and clamor,
I will keep singing loudly and give up everything that controls me.
So I only wish that silence can echo once again.
No need to fear; dawn has already arrived.
Problem Description
Given a sequence of length and a positive integer .
You can perform operations on the sequence . In each operation, you need to choose an index such that is or or , and then flip (that is, change to , and change to ).
Please make the sequence become all 's or all 's within operations. You do not need to minimize the number of operations. If it cannot be done, you need to report that there is no solution.
The testdata guarantees that or . For details, please see the Constraints section.
Input Format
The first line contains two positive integers .
The second line contains integers .
Output Format
If it is impossible to make the sequence become all 's or all 's within operations, output one line with one integer .
If there exists a constructive solution, output two lines:
- The first line contains a non-negative integer , meaning the number of operations; you need to ensure , and you do not need to minimize .
- The second line contains positive integers, representing the index chosen in each operation in order.
4 1000000
0 0 1 0
3
2 4 1
5 1000000
1 1 1 1 1
0
10 1000000
0 1 0 0 1 1 0 0 1 0
18
1 2 10 1 9 4 10 4 7 4 7 3 7 8 9 2 10 1
Hint
[Sample Explanation #1]
The sequence after each operation is, respectively:
- ;
- ;
- 。
At this time, all elements in the sequence are the same.
[Constraints]
For all testdata, , , and or .
This problem uses bundled tests.
- Subtask 1 (20 points): , .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Translated by ChatGPT 5