Codeforces Round 1081 (Div. 2)
B
Flipping Binary String
Codeforces
1000
原题
← AC →
翻译中…

You are given a binary string $s$ of length $n$. You can perform the following operation on the string:

翻译中…
  • Choose an index $i$, and flip the bit present at all other indices except for the index $i$. In other words, choose an integer $i$ ($1 \le i \le n$), and for all $j$ such that $1 \le j \le n$ and $j \ne i$, if $s_j = 0$, then set $s_j:=1$, otherwise set $s_j:=0$.
翻译中…

You can perform the operation any number of times, but each index can be chosen by at most one operation.

翻译中…

Your task is to make all bits present in the string $s$ equal $0$, or report that it is impossible to do so. You don't have to minimize the number of operations.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

The first line of each test case contains a single integer $n$ ($1 \le n \le 2 \cdot 10^5$).

翻译中…

The second line of each test case contains the binary string $s$ of length $n$.

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.

翻译中…

Output

翻译中…

For each test case, output $-1$ if it is impossible to transform all bits to $0$. Otherwise, output two lines in the following format:

翻译中…
  • In the first line, print the number of operations $x$ ($0 \leq x \leq n$).
  • In the second line of each test case, print $x$ numbers – the indices you select in each operation in order. You should guarantee that each index is chosen at most once.
翻译中…

If there are multiple possible solutions, you may output any.

翻译中…

Note

翻译中…

In the first test case, performing the operation on index $2$ means flipping bits present at index $1$ and $3$. So the new string formed will be $000$.

翻译中…

In the second test case, it can be shown that we cannot make string $a$ equal to $000$ using the described operations.

翻译中…

样例

Input #1
4
3
101
3
100
4
0000
4
1010
Output #1
1
2
-1
0
2
1 3
InputCopy OutputCopy
题目信息
题号
2192B
时间限制
1.5 s
内存限制
256 MB
标签
构造
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。