#P2148. [SDOI2009] E&D

    ID: 1126 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>博弈论2009各省省选树状数组山东枚举,暴力状态压缩,状压

[SDOI2009] E&D

Description

E and W play a game called E&D.

The rules are as follows: There are 2n2n piles of stones on the table, numbered 12n1 \sim 2n. For convenience, we regard pile 2k12k-1 and pile 2k2k (1kn1 \le k \le n) as one group. The number of stones in pile ii is a positive integer SiS_i.

One split operation is defined as follows: choose any pile of stones and remove it from the table. Then split the other pile in the same group, take some stones from it, and place them at the removed position to form a new pile. After the operation, the number of stones in every pile must be greater than 00. Obviously, the pile being split must contain at least 22 stones. The two players alternate performing split operations. If, on a player's turn, all piles have exactly 11 stone, then no move is possible and that player loses.

E makes the first move. He wants to know whether there exists a strategy that guarantees he can defeat W. Therefore, he asks F (you) to tell him whether a winning strategy exists. For example, suppose initially there are 44 piles with sizes 1,2,3,11,2,3,1. E can choose to remove pile 11, then split pile 22 (he can only split off 11 stone). Next, W can only remove pile 44, then split pile 33 into 11 and 22. Finally, it is E's turn; he can only remove the pile of size 11 among the last two piles, and split the other into 11 and 11. Thus, when it is W's turn, all piles have size 11, so he loses. Therefore, E has a winning strategy.

Input Format

There are multiple test cases in this problem.

The first line contains an integer TT, the number of test cases.

For each test case:

The first line contains an integer NN, the total number of piles on the table; here NN is the 2n2n from the problem description.

The second line contains NN integers S1NS_{1 \dots N}.

Output Format

For each test case, if E has a winning strategy, output a single string YES; otherwise, output a single string NO.

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

YES
NO

Hint

For 20%20\% of the testdata, N=2N=2.

For another 20%20\% of the testdata, N4N \le 4, Si50S_i \le 50.

For 100%100\% of the testdata, 1T201 \le T \le 20, 1N2×1041 \le N \le 2 \times 10^4 and NN is even, 1Si2×1091 \le S_i \le 2 \times 10^9.

Translated by ChatGPT 5