#P10854. 【MX-X2-T3】「Cfz Round 4」Ninelie

    ID: 12328 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>Special JudgeO2优化构造折半搜索 meet in the middle梦熊比赛

【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 0101 sequence a1,,ana_1, \ldots, a_n of length nn and a positive integer rr.

You can perform operations on the sequence aa. In each operation, you need to choose an index pp such that pp is 11 or nn or ap1ap+1a_{p-1}\neq a_{p+1}, and then flip apa_p (that is, change 00 to 11, and change 11 to 00).

Please make the sequence aa become all 00's or all 11's within rr 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 r=2×106\bm{r = 2 \times 10^6} or 106\bm{10^6}. For details, please see the Constraints section.

Input Format

The first line contains two positive integers n,rn, r.

The second line contains nn integers a1,,ana_1, \ldots, a_n.

Output Format

If it is impossible to make the sequence aa become all 00's or all 11's within rr operations, output one line with one integer 1-1.

If there exists a constructive solution, output two lines:

  • The first line contains a non-negative integer mm, meaning the number of operations; you need to ensure mrm\le r, and you do not need to minimize m\bm m.
  • The second line contains mm positive integers, representing the index pp 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 aa after each operation is, respectively:

  • [0,1,1,0][0,1,1,0]
  • [0,1,1,1][0,1,1,1]
  • [1,1,1,1][1,1,1,1]

At this time, all elements in the sequence aa are the same.

[Constraints]

For all testdata, 2n2×1032\le n\le 2\times 10^3, ai{0,1}a_i\in\{0,1\}, and r=2×106r = 2 \times 10^6 or 10610^6.

This problem uses bundled tests.

  • Subtask 1 (20 points): n10n\le 10, r=2×106r=2\times 10^6.
  • Subtask 2 (30 points): r=2×106r=2\times 10^6.
  • Subtask 3 (50 points): r=106r=10^6.

Translated by ChatGPT 5