P10168 [DTCPC 2024] 0=1=0

Description

You are given a string $s$ that contains only $0$ and $1$. Each time, you may choose an index $i\in [1,n)$, and flip $s_i$ and $s_{i+1}$ separately. Flipping $1$ results in $0$, and flipping $0$ results in $1$. You need to maximize the number of ordered pairs, i.e., maximize the number of pairs $(i,j)$ such that $i\lt j$ and $s_i\lt s_j$. Output a solution.

Input Format

One line containing a string $S$ ($\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 $x$, representing the number of operations. Then output one line with $x$ numbers. The $i$-th number $a_i$ means that in the $i$-th operation, you flip $s_{a_i}$ and $s_{a_i+1}$. **You must ensure that the number of operations does not exceed $2\times 10^5$, but you do not need to minimize the number of operations.**

Explanation/Hint

Translated by ChatGPT 5