Codeforces Round 906 (Div. 2)
C
Qingshan Loves Strings 2
Codeforces
未评级
原题
← BD →
翻译中…

Qingshan has a string $s$ which only contains $\texttt{0}$ and $\texttt{1}$.

翻译中…

A string $a$ of length $k$ is good if and only if

翻译中…
  • $a_i \ne a_{k-i+1}$ for all $i=1,2,\ldots,k$.
翻译中…

For Div. 2 contestants, note that this condition is different from the condition in problem B.

翻译中…

For example, $\texttt{10}$, $\texttt{1010}$, $\texttt{111000}$ are good, while $\texttt{11}$, $\texttt{101}$, $\texttt{001}$, $\texttt{001100}$ are not good.

翻译中…

Qingshan wants to make $s$ good. To do this, she can do the following operation at most $300$ times (possibly, zero):

翻译中…
  • insert $\texttt{01}$ to any position of $s$ (getting a new $s$).
翻译中…

Please tell Qingshan if it is possible to make $s$ good. If it is possible, print a sequence of operations that makes $s$ good.

翻译中…

Input

翻译中…

The input consists of multiple test cases. The first line contains a single integer $t$ ($1\le t\le 100$) — the number of test cases. The description of the test cases follows.

翻译中…

The first line of each test case contains a single integer $n$ ($1 \le n\le 100$) — the length of string $s$, respectively.

翻译中…

The second line of each test case contains a string $s$ with length $n$.

翻译中…

It is guaranteed that $s$ only consists of $\texttt{0}$ and $\texttt{1}$.

翻译中…

Output

翻译中…

For each test case, if it impossible to make $s$ good, output $-1$.

翻译中…

Otherwise, output $p$ ($0 \le p \le 300$) — the number of operations, in the first line.

翻译中…

Then, output $p$ integers in the second line. The $i$-th integer should be an index $x_i$ ($0 \le x_i \le n+2i-2$) — the position where you want to insert $\texttt{01}$ in the current $s$. If $x_i=0$, you insert $\texttt{01}$ at the beginning of $s$. Otherwise, you insert $\texttt{01}$ immediately after the $x_i$-th character of $s$.

翻译中…

We can show that under the constraints in this problem, if an answer exists, there is always an answer that requires at most $300$ operations.

翻译中…

Note

翻译中…

In the first test case, you can do zero operations and get $s=\texttt{01}$, which is good.

翻译中…

Another valid solution is to do one operation: (the inserted $\texttt{01}$ is underlined)

翻译中…
  1. $\texttt{0}\underline{\texttt{01}}\texttt{1}$
翻译中…

and get $s = \texttt{0011}$, which is good.

翻译中…

In the second and the third test case, it is impossible to make $s$ good.

翻译中…

In the fourth test case, you can do two operations:

翻译中…
  1. $\texttt{001110}\underline{\texttt{01}}$
  2. $\texttt{0011100}\underline{\texttt{01}}\texttt{1}$
翻译中…

and get $s = \texttt{0011100011}$, which is good.

翻译中…

样例

Input #1
6
2
01
3
000
4
1111
6
001110
10
0111001100
3
001
Output #1
0

-1
-1
2
6 7
1
10
-1
InputCopy OutputCopy
题目信息
题号
1890C
时间限制
1 s
内存限制
256 MB

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