#P14787. [NERC 2025] Fragmented Nim
[NERC 2025] Fragmented Nim
题目描述
The classical game of Nim goes as follows. There are piles of stones, and pile initially consists of stones. Alice and Bob take turns; Alice goes first. On their turn, a player chooses any non-empty pile and removes any positive number of stones from it. The player who takes the last stone wins.
After playing a lot of Nim, Alice and Bob decided to vary the rules a little bit. In this variation, the player whose turn it is does not choose a pile — their opponent does it for them! However, the player still gets to decide the number of stones to remove from that pile.
Alice still moves first. On Alice’s turn Bob chooses any non-empty pile, and then Alice removes any positive number of stones from it. Similarly, on Bob’s turn Alice chooses any non-empty pile, and then Bob removes any positive number of stones from it.
For the given configuration of stones in the piles, determine who will win if both players follow the optimal strategy.
输入格式
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains a single integer , denoting the number of piles ().
The second line contains integers , denoting the number of stones in the piles ().
It is guaranteed that the sum of over all test cases does not exceed .
输出格式
For each test case, print the name of the winner of the game if both players follow the optimal strategy: “Alice” or “Bob”.
3
3
1 2 3
1
1
5
10 3 4 7 4
Bob
Alice
Alice
提示
In the first test case, here’s one possible way the game could proceed:
- Bob chooses the first pile. Alice removes 1 stone from it.
- Alice chooses the third pile. Bob removes 2 stones from it.
- Bob chooses the third pile. Alice removes 1 stone from it.
- Alice chooses the second pile. Bob removes 2 stones from it and wins.
In the second test case, Bob chooses the only pile, and Alice wins by removing the only stone from it.