No.3258 Xor Division Game
タグ : / 解いたユーザー数 22
作問者 :
Iroha_3856
/ テスター :
champignon
Problem Statement
There is a multiset $S$ of integer sequences.
Initially, $S = \{(F_1, F_2, \ldots, F_N)\}$. Here, it is guaranteed that $F$ does not contain $0$.
For an integer sequence $A = (A_1, A_2, \ldots, A_K)$ with $A \in S$, splitting $A$ at position $i\ (1 \leq i \leq K)$ is defined as performing the following operations in order.
- If $i \neq 1$, add $(A_1 \oplus A_i, A_2 \oplus A_i, \ldots, A_{i-1} \oplus A_i)$ to $S$.
- If $i \neq K$, add $(A_{i+1} \oplus A_i, A_{i+2} \oplus A_i, \ldots, A_K \oplus A_i)$ to $S$.
- Remove $1$ copy of $A$ from $S$.
Alice and Bob play the following game using $S$.
-
Starting with Alice, the players alternately perform the following operation.
- Choose any integer sequence $A$ with $A \in S$ and an $i$ such that $1 \leq i \leq |A|$, and split $A$ at position $i$.
- However, an operation after which $S$ contains a sequence containing $0$ must not be performed.
Determine who wins when both players play optimally.
Input
$N$ $F_1\ F_2\ \ldots\ F_N$
All input satisfies the following constraints.
- $1 \leq N \leq 2 \times 10^5$
- $1 \leq F_i < 2^{30}$
- All input values are integers.
Output
If Alice wins when both players play optimally, print Alice; if Bob wins, print Bob.
Print a newline at the end.
Sample
Sample 1
Input
6 1 2 2 1 5 7
Output
Bob
For example, the game may proceed as follows:
Initially, $S = \{(1, 2, 2, 1, 5, 7)\}$.
Alice chooses the sequence $A = (1, 2, 2, 1, 5, 7) \in S$ and splits $A$ at position $5$.
After this, $S = \{(1 \oplus 5, 2 \oplus 5, 2 \oplus 5, 1 \oplus 5), (7 \oplus 5)\} = \{(4, 7, 7, 4), (2)\}$.
Bob chooses the sequence $A = (2) \in S$ and splits $A$ at position $1$.
After this, $S = \{(4, 7, 7, 4)\}$.
Since an operation that produces $0$ cannot be performed, Alice cannot perform any operation at this point, so Alice loses and Bob wins.
No matter how Alice plays, Bob wins by playing appropriately, so print Bob.
Sample 2
Input
1 1
Output
Alice
Initially, $S = \{(1)\}$.
Alice chooses the sequence $A = (1) \in S$ and splits $A$ at position $1$.
After this, $S = \{\}$.
Bob cannot perform any operation after this, so Bob loses and Alice wins.
Therefore, print Alice.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。