No.1716 Bonus Nim
Problem Statement
Alice and Bob play a game.
Initially there are $N$ piles, and the $i$-th pile has $A_i$ stones on it.
Starting with Alice, the $2$ players alternately and repeatedly choose one of the following operations.
- Choose $1$ pile that has $1$ or more stones remaining. If the chosen pile has $X$ stones, remove any number of stones between $1$ and $X$, inclusive, from that pile. If all the stones are removed, that is, if $X$ stones are removed, the player gets $1$ coin as a bonus.
- Discard $1$ coin that the player has.
The player who first becomes unable to perform an operation loses.
Initially, neither Alice nor Bob has any coins. Determine who wins when both Alice and Bob act optimally in order to win.
For each input file, answer $T$ test cases.
Constraints
- All input values are integers.
- $1 \le T\le 2 \times 10^5$
- $1 \le N \le 2 \times 10^5 $
- $1 \le A_i\le 10^9 $
- In $1$ input file, the sum of $N$ is at most $5\times 10^5$.
Input
The input is given from standard input in the following format.
$T$
$\mathrm{case}_1$
$\vdots$
$\mathrm{case}_T$
Each test case is given in the following format.
$N$ $A_1$ $A_2$ $\dots$ $A_N$
Output
Output $T$ lines. On the $i\ (1\le i \le T)$-th line, output Alice if the winner of the $i$-th test case is Alice, and Bob if it is Bob.
Sample
Sample 1
Input
2 1 3 2 1 1
Output
Alice Bob
For example, the following scenario is possible in the $2$-nd game.
- Alice performs operation $1$, choosing the $1$-st pile and removing $1$ stone. Since the $1$-st pile has no stones left, she gets $1$ coin.
- Bob performs operation $1$, choosing the $2$-nd pile and removing $1$ stone. Since the $2$-nd pile has no stones left, he gets $1$ coin.
- Alice performs operation $2$, discarding $1$ coin.
- Bob performs operation $2$, discarding $1$ coin.
- Alice cannot perform any more operations, so she loses. Bob wins.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
nok0
Kite_kuma