QOJ.ac

QOJ

Limite de temps : 3.0 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓

#15898. 碎片尼姆游戏

Statistiques

经典的尼姆博弈(Nim)规则如下:有 $n$ 堆石子,第 $i$ 堆最初有 $a_i$ 个石子。Alice 和 Bob 轮流操作,Alice 先手。在每个玩家的每个回合中,玩家选择任意一个非空石子堆,并从中拿走任意正整数个石子。拿走最后一个石子的玩家获胜。

在玩了许多局尼姆博弈后,Alice 和 Bob 决定稍微改变一下规则。在这个变种中,轮到某个玩家操作时,该玩家不能自己选择石子堆——而是由他们的对手来为他们选择!然而,该玩家仍然可以决定从该堆中拿走多少个石子。

Alice 仍然先手。在 Alice 的回合中,Bob 选择任意一个非空石子堆,然后 Alice 从中拿走任意正整数个石子。类似地,在 Bob 的回合中,Alice 选择任意一个非空石子堆,然后 Bob 从中拿走任意正整数个石子。

给定各堆石子的初始配置,判断如果双方都采取最优策略,谁将获胜。

输入格式

每个测试点包含多个测试用例。第一行包含测试用例的数量 $t$($1 \le t \le 10^4$)。接下来是测试用例的描述。

每个测试用例的第一行包含一个整数 $n$,表示石子堆的数量($1 \le n \le 2 \cdot 10^5$)。

第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$,表示每堆石子的数量($1 \le a_i \le 10^9$)。

保证所有测试用例中 $n$ 的总和不超过 $2 \cdot 10^5$。

输出格式

对于每个测试用例,如果双方都采取最优策略,输出游戏获胜者的名字:“Alice” 或 “Bob”。

样例

输入 1

3
3
1 2 3
1
1
5
10 3 4 7 4

输出 1

Bob
Alice
Alice

说明

在第一个测试用例中,游戏的一种可能进行方式如下:

  • Bob 选择第一堆。Alice 从中拿走 1 个石子。
  • Alice 选择第三堆。Bob 从中拿走 2 个石子。
  • Bob 选择第三堆。Alice 从中拿走 1 个石子。
  • Alice 选择第二堆。Bob 从中拿走 2 个石子并获胜。

在第二个测试用例中,Bob 选择仅有的一堆,Alice 通过拿走其中唯一的石子而获胜。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.