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

28155번 - Splitting Pairs 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB79474362.319%

문제

Alice and Bob are playing a modified game of Nim. Initially, there are some non-empty piles of stones in front of them. They take turns, and Alice takes the first turn.

On a single turn, a player must do the following actions in order:

  • Remove some number of piles of stones --- at least one but no more than half the number of piles.
  • Choose the same number of piles of remaining stones, and split each of those piles into two non-empty piles.

Notice that after each valid move, there should be the same number of non-empty piles of stones as at the start of the game. A player who cannot perform all the actions on their turn loses the game.

You are given many games, and for each one, you'd like to determine who would win if both players play optimally.

입력

The first line of input contains an integer $t$ (1ドル \leq t \leq 1,000円$), which is the number of games Alice and Bob play.

Each game is represented on two lines. The first line of each game contains an integer $n$ (2ドル \leq n \leq 50$), which is the number of piles of stones.

The next line of the game contains $n$ space-separated integers $s$ (1ドル \leq s \leq 10^{12}$), which are the number of stones in each pile.

출력

Output $t$ lines. For each game, output a single line with a single integer, which is 1ドル$ if Alice wins and 0ドル$ if Bob wins. Assume Alice takes the first turn, and both players play optimally. Output the game results in the order the games appear in the input.

제한

예제 입력 1

4
3
1 1 1
3
1 1 2
3
2 2 2
4
4 4 4 4

예제 출력 1

0
1
0
1

힌트

출처

ICPC > Regionals > North America > North America Championship > North America Championship 2023 L번

  • 문제를 만든 사람: Lewin Gan
(追記) (追記ここまで)

출처

대학교 대회

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

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