Logo
(追記) (追記ここまで)

31186번 - Secret of Tianqiu Valley 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB29151257.143%

문제

In the north tower of Tianqiu Valley's ruins, there are some flame torch puzzles and Lumine the traveler is facing the last and the hardest one.

Source: Genshin Impact Official

There are $n$ torches in a circle and some torches have been ignited initially. The $i$-th and the $(i \bmod n +1)$-th are adjacent for all 1ドル \le i \le n$.

To solve the puzzle, all the torches should be ignited. In each move, Lumine can ignite an extinguished torch, and the status of the adjacent torches will be reversed affected by the supernatural. That is, each of the adjacent torches will be ignited if it is currently extinguished, or be extinguished if it is currently ignited.

Time is money, Lumine wants to solve the puzzle in 2ドルn$ moves or determine that the puzzle is unsolvable.

입력

There are multiple test cases. The first line of the input contains an integer $T$ indicating the number of test cases. For each test case:

The first line of the input contains an integer $n$ (3ドル \le n \le 10^5$) indicating the number of torches in the circle.

The second line contains a binary string $s_1s_2\cdots s_n$ of length $n$ ($s_i \in \{\text{'0'}, \text{'1'}\}$). If $s_i = \text{'0'}$ the $i$-th torch is extinguished initially; If $s_i = \text{'1'}$ the $i$-th torch is ignited initially. It is guaranteed that not all the torches have been ignited initially.

It is also guaranteed that the sum of $n$ of all test cases will not exceed 10ドル^6$.

출력

If the puzzle is unsolvable, output "0" (without quotes).

Otherwise, output an integer $k$ $(1 \le k \le 2n)$ in the first line indicating the number of moves Lumine needs to solve the puzzle. Then output a line containing $k$ integers $t_1, t_2, \cdots, t_k$ separated by a space, where $t_i$ indicating that Lumine will ignite the $t_i$-th torch in the $i$-th move. If there are multiple answers print any of them.

제한

예제 입력 1

2
5
00000
3
001

예제 출력 1

7
2 5 1 2 3 4 2
0

노트

For the first sample test case, the status of the torch will change like this: 00000ドル$ $\to$ 11100ドル$ $\to$ 01111ドル$ $\to$ 10110ドル$ $\to$ 01010ドル$ $\to$ 00100ドル$ $\to$ 00011ドル$ $\to$ 11111ドル$.

출처

Contest > Open Cup > 2021/2022 Season > Stage 9: Grand Prix of Nanjing L번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /