QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 64 MB 總分: 100 可 Hack ✓

#6789. 又一个取石子游戏

统计

Alice 和 Bob 正在玩另一个取石子游戏。游戏规则如下:

  • 游戏开始时有 $n$ 堆石子,编号从 $1$ 到 $n$。第 $i$ 堆石子包含 $a_i$ 个石子,并有一个特殊的限制 $b_i$。
  • 玩家轮流进行操作。两位玩家的合法操作不同。
  • Bob 的合法操作是从某一堆中移除任意正整数个石子。
  • Alice 的合法操作也是从某一堆中移除任意正整数个石子,但受到该堆限制 $b_i$ 的约束:
    • 若 $b_i = 0$,则没有限制。
    • 若 $b_i = 1$,Alice 只能从该堆中移除奇数个石子。
    • 若 $b_i = 2$,Alice 只能从该堆中移除偶数个石子。 请注意,Bob 没有受到任何限制。
  • 无法进行合法操作的玩家输掉游戏。

Alice 总是先手。如果双方都采取最优策略,你知道谁会赢吗?

输入格式

输入包含多组测试数据。第一行包含一个整数 $T$,表示测试数据的组数。对于每组测试数据:

第一行包含一个整数 $n$ ($1 \le n \le 10^5$),表示石子堆的数量。 第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$),表示每堆石子的数量。 第三行包含 $n$ 个整数 $b_1, b_2, \dots, b_n$ ($0 \le b_i \le 2$),表示每堆石子的特殊限制。

保证所有测试数据的 $n$ 之和不超过 $10^6$。

我们提醒您,本题涉及大量 I/O 操作,建议使用较快的 I/O 方法。例如,在 C++ 中可以使用 scanf/printf 代替 cin/cout

输出格式

对于每组测试数据,如果 Alice 获胜,输出 “Alice”(不含引号);否则,输出 “Bob”(不含引号)。

样例

输入 1

3
2
4 1
1 0
1
3
2
1
1
2

输出 1

Alice
Bob
Bob

说明 1

对于第一组测试数据,Alice 可以从第一堆中移除 3 个石子,然后她将赢得游戏。

对于第二组测试数据,由于 Alice 只能移除偶数个石子,她无法在第一步中移除所有石子。因此 Bob 可以在他的回合移除剩余的所有石子并赢得游戏。

对于第三组测试数据,Alice 在游戏开始时无法移除任何数量的石子,因此 Bob 获胜。

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.