#P14787. [NERC 2025] Fragmented Nim

[NERC 2025] Fragmented Nim

题目描述

The classical game of Nim goes as follows. There are nn piles of stones, and pile ii initially consists of aia_i 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 tt (1t1041 \le t \le 10^4). The description of the test cases follows.

The first line of each test case contains a single integer nn, denoting the number of piles (1n21051 \le n \le 2 \cdot 10^5).

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n, denoting the number of stones in the piles (1ai1091 \le a_i \le 10^9).

It is guaranteed that the sum of nn over all test cases does not exceed 21052 \cdot 10^5.

输出格式

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.