1D Super Checkers Solitaire

시간 제한1초메모리 제한2048 MB

요약
검은 토큰을 한 칸씩 왼쪽으로 옮기면 컴퓨터가 연속 구간의 길이를 XOR로 점수에 더한다. 점수를 0으로 만들 수 있는지 판정한다.
난이도

어려움10점 중 8점

유형
게임 이론, 그리디, 동적 계획법, 수학
정답자
아직 제출이 없습니다

문제

You are playing the new hit computer game, "1D Super Checkers Solitaire"!

The game is played on a number line. Initially, a white token is placed at position −1-1, and nn black tokens are placed at distinct positions x_1,x_2,…,x_nx\_1, x\_2, \dots, x\_n (with 1≤x_i≤1091 \le x\_i \le 10^9). Note that position 00 will never initially contain a token of either color. There is also a score counter, ss, which is initially 00.

On each turn, you move a black token one step to the left, under the restriction that tokens cannot overlap.

After each of your moves, the computer, playing the white token, repeats the following process while there is a black token immediately to the right of the white token:

  • Let ii be the current position of the white token, and let kk be the number of contiguous black tokens starting at position i+1i+1 (i.e., tokens at positions i+1,i+2,…,i+ki+1, i+2, \dots, i+k, with position i+k+1i+k+1 empty).
  • The white token jumps over and removes these kk black tokens, landing at position i+k+1i+k+1.
  • The score counter is updated to s=s⊕ks = s \oplus k (where ⊕\oplus denotes the bitwise XOR operation).

Finally, you regain control, and can take another turn if there are black tokens remaining.

Here is an example turn. The board could initially look like this:

You could choose to move a black token from position 11 to position 00, resulting in this configuration:

The computer would then repeatedly jump over the ranges of black tokens next to it, ending up at position 66:

After these moves, the score would become 0⊕1⊕2⊕1=20 \oplus 1 \oplus 2 \oplus 1 = 2, and the game would continue, since there are more black tokens remaining.

The game ends when there are no more black tokens.

At the end of the game, you win only if and only if ss is equal to 00. Determine whether you can win if you play optimally.

입력

The first line of the input contains a single integer tt (1≤t≤1041 \le t \le 10^4) --- the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer nn (1≤n≤2⋅1051 \le n \le 2 \cdot 10^5) --- the number of black tokens.

The second line of each test case contains nn integers x_1<x_2<⋯ ,x_nx\_1 < x\_2 < \cdots, x\_n (1≤x_i≤1091 \le x\_i \le 10^9) --- the initial positions of the black tokens, in strictly increasing order.

출력

For each test case, print "YES" if you can win if you play optimally, or "NO" otherwise.

힌트

In the first sample case, one winning move you can make is moving a black piece from position 11 to position 00.

The computer will then jump over all 44 consecutive groups of your pieces, and the score will be set to 0⊕1⊕1⊕1⊕2⊕2=00 \oplus 1 \oplus 1 \oplus 1 \oplus 2 \oplus 2 = 0:

Since there are no remaining black tokens, the game ends, and since s=0s = 0, you win.

In the second sample case, since n=1n=1, the score will always be s=1s = 1 at the end of the game, and you will lose.

예제1

  1. 예제 1

    입력
    3
    6
    1 2 4 5 7 8
    1
    456
    10
    1 4 5 6 7 10 11 12 13 14
    
    예상 출력
    YES
    NO
    YES