CF2181B.Battle of Arrays

普及/提高-

通过率:0%

时间限制:3.00s

内存限制:1024MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Alice and Bob play a turn-based game. Initially, Alice has an array aa of nn positive integers, and Bob has an array bb of mm positive integers. The players take turns, with Alice moving first.

On a player's turn, they must choose one element xx from their own array and the maximal element yy from their opponent's array. Then they perform the following operation:

  • If y≤xy \leq x: the element yy is destroyed (removed from the opponent's array).
  • If y>xy \gt x: the element yy is decreased by xx (the value of yy becomes y−xy - x).

A player wins if, after their move, the opponent's array becomes empty.

Assuming both players play optimally, determine the winner.

爱丽丝和鲍勃进行一场回合制游戏。初始时,爱丽丝拥有一个包含 nn 个正整数的数组 aa,鲍勃拥有一个包含 mm 个正整数的数组 bb。双方轮流行动,爱丽丝先手。

在某位玩家的回合中,该玩家必须从自己的数组中选择一个元素 xx,并从对手的数组中选择最大元素 yy。然后执行以下操作:

  • 若 y≤xy \leq x:元素 yy 被摧毁(即从对手的数组中移除);
  • 若 y>xy > x:元素 yy 减少 xx(即 yy 的值变为 y−xy - x)。

若某位玩家在完成自己的操作后,使得对手的数组变为空,则该玩家获胜。

假设双方均以最优策略进行游戏,请判断最终的获胜者。

输入格式

Each input contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1051 \le t \le 10^5).

The first line of each test case contains two integers nn and mm (1≤n,m≤1051 \le n,m \le 10^5) — the sizes of Alice's and Bob's arrays respectively.

The second line contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤1091 \le a_i \le 10^9) — Alice's array.

The third line contains mm integers b1,b2,…,bmb_1, b_2, \ldots, b_m (1≤bi≤1091 \le b_i \le 10^9) — Bob's array.

It is guaranteed that the sum of nn over all test cases does not exceed 10510^5 and the sum of mm over all test cases does not exceed 10510^5.

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

每个测试用例的第一行包含两个整数 nn 和 mm(1≤n,m≤1051 \le n,m \le 10^5)—— 分别表示爱丽丝和鲍勃的数组长度。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤1091 \le a_i \le 10^9)—— 爱丽丝的数组。

第三行包含 mm 个整数 b1,b2,…,bmb_1, b_2, \ldots, b_m(1≤bi≤1091 \le b_i \le 10^9)—— 鲍勃的数组。

保证所有测试用例中 nn 的总和不超过 10510^5,且所有测试用例中 mm 的总和不超过 10510^5。

输出格式

For each test case, print the name of the winner of the game if both players follow the optimal strategy: "Alice" or "Bob".

对于每个测试用例,若双方玩家均采用最优策略,则输出游戏获胜者的名字:“Alice”或“Bob”。

输入输出样例

  • 输入#1

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

    输出#1

    Alice
    Bob

说明/提示

In the first test Alice moves and decreases Bob's element by 7070, so it becomes 2020. Then Bob moves and decreases Alice's element by 2020, so it becomes 5050. Finally, Alice moves, destroys Bob's element, and wins.

在第一组测试中,爱丽丝先行动,将鲍勃的元素减小 7070,使其变为 2020;接着鲍勃行动,将爱丽丝的元素减小 2020,使其变为 5050;最后爱丽丝行动,摧毁鲍勃的元素并获胜。

输入解题思路,AI测评打分。不知道怎么写?

首页