QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 256 MB Puntuación total: 100

#11099. 鍵への衝撃

Estadísticas

Goran は膝の手術から回復中で、暗号鍵を保存するスマートカードを使った実験をしています。この問題では、鍵とは、正の整数 $n$ に対する長さ $3n$ のビット列です。鍵の各ビットには、左から右に $1$ から $3n$ までの整数で番号が付けられています。鍵の重みは、値が異なる隣接ビットの組の個数に $1$ を加えたものです。例えば、鍵 000 の重みは $1$、鍵 011010100 の重みは $7$ です。

彼は、スマートカードの回路に小さな電気ショックを与えることで、鍵を改変できると発見しました。具体的には、鍵の任意の隣接する 2 ビットを選び、両方を反転させる操作を確実に行えます。例えば、1 回の操作で鍵 000 を 110 に変えられます。

長さ $3n$ の鍵が与えられます。高々 $n$ 回の操作で、その鍵を重みが $2n$ 以上の鍵に変換する任意の操作列を求めてください。解は必ず存在すると仮定してかまいません。

入力

最初の行には、初期の鍵を表す、数字 0 と 1 からなる文字列が与えられます。鍵の長さは $3n$ で、$n$ は $1 \le n \le 100\,000$ を満たす正の整数です。

出力

最初の行には、あなたの解における操作回数を表す整数 $m$($0 \le m \le n$)を出力してください。次の行には、解を記述する $m$ 個の整数 $a_1,a_2,\ldots,a_m$ を出力してください。$a_k$ は、$k$ 回目の操作で反転する 2 ビットのうち左側のビットの番号です。

初期の鍵の重みがすでに $2n$ 以上である場合、整数 $0$ のみを出力してもかまいません。

入出力例

入力 1

000000000

出力 1

3
2 5 6

入力 2

111001000111

出力 2

2
3 9

入力 3

010101

出力 3

0

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.