独立尼姆游戏AI (CI翻译)
Problem Statement
题目描述
AI (CI翻译)There is an integer sequence $A$ of length $N$. Each element of $A$ is $0$ or $1$.
有一个长度为 $N$ 的整数序列 $A$。$A$ 的每个元素都是 $0$ 或 $1$。AI (CI翻译)
Alice and Bob play a game. Starting with Alice, they alternately perform the following operation.
Alice 和 Bob 正在进行一个游戏。由 Alice 先手,双方交替执行以下操作。AI (CI翻译)
- Choose one or more elements of
$A$that are$1$, and set them to$0$. Here, it is forbidden to choose adjacent elements simultaneously.
- 选择
$A$中一个或多个值为$1$的元素,并将它们设为$0$。其中,禁止同时选择相邻的元素。
The player who is first unable to perform the operation loses.
无法进行操作的玩家输掉游戏。AI (CI翻译)
Determine which player wins when both players play optimally.
假设双方都采取最优策略,判断哪位玩家获胜。AI (CI翻译)
You are given $T$ test cases; solve each of them.
给定 $T$ 组测试用例,请分别求出每组测试用例的答案。AI (CI翻译)
Constraints
约束条件
AI (CI翻译)$1 \le T \le 10^5$$1 \le N \le 2\times 10^5$$A_i = 0$or$A_i = 1$.- The sum of
$N$over all test cases is at most$2\times 10^5$. - All input values are integers.
$1 \le T \le 10^5$$1 \le N \le 2\times 10^5$$A_i = 0$或$A_i = 1$。- 所有测试用例的
$N$之和不超过$2\times 10^5$。 - 所有输入值均为整数。
Input
输入格式
AI (CI翻译)The input is given from Standard Input in the following format:
输入从标准输入按以下格式给出:AI (CI翻译)
T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T
T
\text{case}_1
\text{case}_2
\vdots
\text{case}_TAI (CI翻译)
Each case is given in the following format:
每组测试用例按以下格式给出:AI (CI翻译)
N
A_1 A_2 \cdots A_N
N
A_1 A_2 \cdots A_NAI (CI翻译)
Output
输出格式
AI (CI翻译)Output $T$ lines. The $i$-th line should contain Alice if Alice wins for $\text{case}_i$, and Bob if Bob wins.
输出 $T$ 行。第 $i$ 行中,如果对于 $\text{case}_i$,Alice 获胜,则输出 Alice;如果 Bob 获胜,则输出 Bob。AI (CI翻译)
样例
3
5
1 0 1 0 1
2
1 1
14
1 1 1 0 1 1 1 1 0 1 1 1 1 1
Alice
Bob
Alice
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。