#P10168. [DTCPC 2024] 0=1=0

[DTCPC 2024] 0=1=0

Problem Description

You are given a string ss that contains only 00 and 11.

Each time, you may choose an index i[1,n)i\in [1,n), and flip sis_i and si+1s_{i+1} separately.

Flipping 11 results in 00, and flipping 00 results in 11.

You need to maximize the number of ordered pairs, i.e., maximize the number of pairs (i,j)(i,j) such that i<ji\lt j and si<sjs_i\lt s_j.

Output a solution.

Input Format

One line containing a string SS (S2×105\lvert S\rvert\leq 2\times 10^5).

Output Format

The first line outputs a number, representing the maximum number of ordered pairs.

The second line outputs a number xx, representing the number of operations.

Then output one line with xx numbers. The ii-th number aia_i means that in the ii-th operation, you flip sais_{a_i} and sai+1s_{a_i+1}.

You must ensure that the number of operations does not exceed 2×1052\times 10^5, but you do not need to minimize the number of operations.

111100
8
2
1 5

Hint

Translated by ChatGPT 5