No.3752 No Use Crying Over Suffixes
Problem Statement
There are $N$ piles, and pile $i$ contains $A_i$ stones.
$2$ players, Alice and Bob, play a game using these piles. Starting with Alice, they alternately perform the following operation.
The player whose turn it is chooses $1$ pile $i$ that has $1$ or more stones and removes $1$ stone from pile $i$.
If this operation causes pile $i$ to have $0$ stones, the numbers of stones in all piles after $i$, namely piles $i+1,i+2,\ldots,N$, also become $0$.
The players repeat this operation as long as there is a pile with $1$ or more stones. A player who cannot perform the operation on their turn loses.
You are given $T$ test cases. For each test case, determine which of Alice and Bob wins when both players play optimally.
Constraints
- $1 \leq T \leq 10^5$
- $1 \leq N$
- $1 \leq A_i \leq 10^{9}$
- The sum of $N$ over all test cases is at most $2 \times 10^5$
- $T$, $N$, $A_i$ are integers
Input
The input is given from standard input in the following format. Here, the $t\ (1 \leq t \leq T)$-th test case is denoted by $\mathrm{case}_t$.
$T$
$\mathrm{case}_1$
$\mathrm{case}_2$
$\vdots$
$\mathrm{case}_T$
Each test case is given in the following format.
$N$ $A_1$ $A_2$ $\dots$ $A_N$
Here, $N$ is the number of piles, and $A_i$ is the number of stones in pile $i$.
Output
Print $T$ lines.
For each test case, print Alice if Alice wins and
Bob if Bob wins, on $1$ line.
Sample
Sample 1
Input
3 2 1 2 3 3 1 2 1 3
Output
Alice Bob Alice
In test case number $1$, Alice can remove $1$ stone from pile $1$. This causes pile $1$ to have $0$ stones, so the stones in pile $1$ and all piles after it, that is, pile $1$ and pile $2$, all become $0$. Therefore, Bob cannot perform the operation, and Alice wins.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
siganai