#P8743. [蓝桥杯 2021 省 A] 异或数列
[蓝桥杯 2021 省 A] 异或数列
Problem Description
Alice and Bob are playing a game with an XOR sequence. At the beginning, Alice and Bob each have an integer and with initial value , and they share a given sequence of length .
Alice and Bob take turns to make moves, with Alice moving first. In each move, one of the following two options can be chosen:
Option 1: Choose an from the sequence and XOR it to Alice's number, i.e., change to . (Here denotes bitwise XOR.)
Option 2: Choose an from the sequence and XOR it to Bob's number, i.e., change to .
Each number can only be used once. When all have been used (after rounds), the game ends. At the end of the game, the player with the larger number wins. If both numbers are equal, the game is a draw.
Now assume both players are smart enough and both use optimal strategies. Determine who will win.
Input Format
Each test file contains multiple queries. The queries are independent.
The first line contains an integer , which is the number of queries.
The next lines each contain one query. In the -th line, the first integer is the length of the sequence, followed by integers , which are the numbers in the sequence.
Output Format
Output lines, each corresponding to the answer for one query.
Each line contains an integer , , or , meaning that Alice wins, the game is a draw, or Alice loses, respectively.
4
1 1
1 0
2 2 1
7 992438 1006399 781139 985280 4729 872779 563580
1
0
1
1
Hint
For all test cases, , $1 \leq \sum\limits_{i=1}^{T} n_{i} \leq 2\times10^5$, .
Lanqiao Cup 2021, Round 1, Provincial Contest, Group A, Problem G.
Translated by ChatGPT 5