#P3677. [CERC2016] 关键的膝盖 Key Knocking

[CERC2016] 关键的膝盖 Key Knocking

Description

Goran is recovering from knee surgery and is experimenting with smart card encryption keys for storage. In this problem, a key is a binary sequence of length 3n3n, where nn is a positive integer. The bits of the sequence are numbered from left to right as 11 to 3n3n. The weight of a key is defined as the number of positions where adjacent bits differ, plus 11. For example, the weight of "000" is 11, and the weight of "011010100" is 77.

He finds that he can send small current pulses to modify the circuits of the smart card, thereby modifying the key. Specifically, he can repeatedly perform the following operation: choose any two adjacent bits and flip them both. For example, he can change "000" to "110" in one operation.

Given a key of length 3n3n, perform at most nn operations to transform it into a key with weight at least 2n2n. You may assume that a valid solution always exists.

Input Format

One line containing a binary string representing the initial key. Its length is exactly 3n3n, where 1n1000001 \le n \le 100000.

Output Format

The first line contains an integer mm denoting the number of operations, with 0mn0 \le m \le n.

The second line contains mm positive integers a1,a2,,ama_1, a_2, \ldots, a_m (1ai<3n1 \le a_i < 3n), in order indicating that in the ii-th operation you flip bits at positions aia_i and ai+1a_i + 1.

If the initial key already has weight at least 2n2n, you may output a single line containing the integer 00.

111001000111

2
3 9

Hint

Translated by ChatGPT 5