QOJ.ac

QOJ

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

#11099. 敲擊金鑰

Estadísticas

Goran 正在膝蓋手術後的康復期間,並研究一張用於儲存密碼金鑰的智慧卡。在本題中,金鑰是一個長度為 $3n$ 的位元字串,其中 $n$ 為正整數。金鑰的各個位元由左至右編號為 $1$ 到 $3n$。金鑰的權重定義為值不同的相鄰位元對數加一。例如,金鑰 000 的權重為 $1$,而金鑰 011010100 的權重為 $7$。

他發現,透過向智慧卡的電路施加微小電流脈衝,就能竄改金鑰。具體而言,他可以可靠地執行以下操作:任意選擇金鑰中兩個相鄰位元,並將兩者同時翻轉。例如,一次操作可以將金鑰 000 變成 110。

給定長度為 $3n$ 的金鑰,找出任意一個長度至多為 $n$ 的操作序列,將其變成權重至少為 $2n$ 的金鑰。你可以假設解一定存在。

輸入格式

第一行包含一個由數字 0 與 1 組成的字串,表示初始金鑰。金鑰長度為 $3n$,其中 $n$ 是滿足 $1\le n\le100\,000$ 的正整數。

輸出格式

第一行應包含一個整數 $m$,滿足 $0\le m\le n$,表示你的方案中的操作次數。下一行應包含 $m$ 個整數 $a_1,a_2,\ldots,a_m$,描述你的方案。數字 $a_k$ 是第 $k$ 步翻轉的兩個位元中左邊那個位元的編號。

如果初始金鑰的權重已經至少為 $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.