CF1889A.Qingshan Loves Strings 2

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

A string aa of length kk is good if and only if

  • aiaki+1a_i \ne a_{k-i+1} for all i=1,2,,ki=1,2,\ldots,k .

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

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

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

  • insert 01\texttt{01} to any position of ss (getting a new ss ).

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

输入格式

The input consists of multiple test cases. The first line contains a single integer tt ( 1t1001\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 nn ( 1n1001 \le n\le 100 ) — the length of string ss , respectively.

The second line of each test case contains a string ss with length nn .

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

输出格式

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

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

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

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

输入输出样例

  • 输入#1

    6
    2
    01
    3
    000
    4
    1111
    6
    001110
    10
    0111001100
    3
    001

    输出#1

    0
    
    -1
    -1
    2
    6 7
    1
    10
    -1

说明/提示

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

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

  1. 0011\texttt{0}\underline{\texttt{01}}\texttt{1}

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

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

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

  1. 00111001\texttt{001110}\underline{\texttt{01}}
  2. 0011100011\texttt{0011100}\underline{\texttt{01}}\texttt{1}

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

首页