QOJ.ac

QOJ

時間限制: 3.0 s 記憶體限制: 1024 MB 總分: 100

#15894. 数组之战

统计

Alice 和 Bob 正在玩一个回合制游戏。最初,Alice 有一个由 $n$ 个正整数组成的数组 $a$,Bob 有一个由 $m$ 个正整数组成的数组 $b$。玩家轮流操作,Alice 先手。

在玩家的回合中,他们必须从自己的数组中选择一个元素 $x$,并从对手的数组中选择一个元素 $y$。然后执行以下操作:

  • 如果 $y \le x$:元素 $y$ 被摧毁(从对手的数组中移除)。
  • 如果 $y > x$:元素 $y$ 的值减少 $x$($y$ 的值变为 $y - x$)。

如果在某位玩家操作后,对手的数组变为空,则该玩家获胜。

假设双方都采取最优策略,请确定获胜者。

输入格式

每个输入包含多个测试用例。第一行包含测试用例的数量 $t$ ($1 \le t \le 10^5$)。

每个测试用例的第一行包含两个整数 $n$ 和 $m$ ($1 \le n, m \le 10^5$) —— 分别表示 Alice 和 Bob 数组的大小。

第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$) —— Alice 的数组。

第三行包含 $m$ 个整数 $b_1, b_2, \dots, b_m$ ($1 \le b_i \le 10^9$) —— Bob 的数组。

保证所有测试用例中 $n$ 的总和不超过 $10^5$,且 $m$ 的总和不超过 $10^5$。

输出格式

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

样例

输入样例 1

2
1 1
70
90
2 3
30 30
20 20 40

输出样例 1

Alice
Bob

说明

在第一个测试用例中,Alice 先手操作,将 Bob 的元素减少 70,使其变为 20。然后 Bob 操作,将 Alice 的元素减少 20,使其变为 50。最后,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 1
IDTypeStatusTitlePosted ByLast UpdatedActions
#429General DiscussionOpen错题hxy_hxy2025-12-18 22:55:42View

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.