Codeforces Round 1014 (Div. 2)
D
Mishkin Energizer
Codeforces
1800
原题
← CE →
翻译中…

In anticipation of a duel with his old friend Fernan, Edmond is preparing an energy drink called "Mishkin Energizer". The drink consists of a string $s$ of length $n$, made up only of the characters L, I, and T, which correspond to the content of three different substances in the drink.

翻译中…

We call the drink balanced if it contains an equal number of all substances. To boost his aura and ensure victory in the duel, Edmond must make the initial string balanced by applying the following operation:

翻译中…
  1. Choose an index $i$ such that $s_i \neq s_{i+1}$ (where $i + 1$ must not exceed the current size of the string).
  2. Insert a character $x$, either L, I, or T, between them such that $x \neq s_i$ and $x \neq s_{i+1}$.
翻译中…

Help Edmond make the drink balanced and win the duel by performing no more than $\textbf{2n}$ operations. If there are multiple solutions, any one of them can be output. If it is impossible, you must report this.

翻译中…

Input

翻译中…

Each test consists of several test cases. The first line of the input data contains one 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 one integer $n$ ($1 \le n \le 100$) — the length of the string $s$.

翻译中…

The second line of each test case contains a string $s$ of length $n$, consisting only of the characters L, I, and T.

翻译中…

Output

翻译中…

For each test case, output $-1$ if there is no solution. Otherwise, in the first line, output a single integer $m$ ($0 \le m \le 2n$) — the number of operations you performed.

翻译中…

Then the $l$-th of the following $m$ lines should contain a single integer $i$ ($1 \le i \lt n+l-1$), indicating the operation of inserting a character between $s_i$ and $s_{i+1}$. It must hold that $s_i \neq s_{i+1}$.

翻译中…

If there are multiple solutions, any one of them can be output. Note that you do not need to minimize the number of operations in this problem.

翻译中…

Note

翻译中…

In the first test case, the following sequence of operations can be performed: TILII $\rightarrow$ TLILII $\rightarrow$ TLTILII $\rightarrow$ TLTLILII $\rightarrow$ TLTLTILII.

翻译中…

In the second test case, no operations can be performed, so the answer is $-1$.

翻译中…

In the third test case, the initial string already has equal quantities of all substances.

翻译中…

样例

Input #1
3
5
TILII
1
L
3
LIT
Output #1
4
1
2
3
4
-1
0
InputCopy OutputCopy
题目信息
题号
2092D
时间限制
2 s
内存限制
256 MB
标签
暴力
构造
贪心
模拟
字符串

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