There are $n$ numbers in a circle where $n$ is odd, each number is either $0$ or $1$, in one operation you can select an index $i$, and the value at that index and at the two adjacent indices facing opposite of index $i$ on that circle are flipped(if the value was $1$ it becomes $0$, and if it was $0$ it becomes $1$). More formally selecting index $i$ will flip the value at indices $i, (i + \lfloor \frac{n}{2} \rfloor - 1 \mod n) + 1, (i - \lfloor \frac{n}{2} \rfloor - 1 \mod n) + 1$.
For example if the numbers are 0010110 and you do an operation on the $6$th index, values at indices $6,2,3$ will be flipped, and the numbers will become 0100100.
Given the $n$ numbers, print a list of operations that will make all the numbers in the circle equal to $1$ using at most $7n$ operations, or state that it's impossible.
The first line contains $n$($ 3 \le n \le 9999$), number of numbers in the circle, $n$ is odd.
The second line contains the $n$ numbers, each number is either $0$ or $1$.
If there is no possible solution using at most $7n$ operations then print "-1" in a single line. Otherwise, let the number of operations be $x$, print $x$ in the first line and $x$ integers $o_1, o_2, ..., o_x$ on the second line, where $o_i$ is the index in which operation $i$ was done on.
This is how the numbers change in the first example: 01110 $\rightarrow$ 10100 $\rightarrow$ 11111
Input | Output |
---|---|
5 01110 Copy
|
2 4 2 Copy
|
3 100 Copy
|
-1 Copy
|