#P14783. [NERC 2025] Battle of Arrays

[NERC 2025] Battle of Arrays

题目描述

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 yxy \le x: the element yy is destroyed (removed from the opponent’s array).
  • If y>xy > x: the element yy is decreased by xx (the value of yy becomes yxy - x).

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

Assuming both players play optimally, determine the winner.

输入格式

Each input contains multiple test cases. The first line contains the number of test cases tt (1t1051 \le t \le 10^5). The first line of each test case contains two integers nn and mm (1n,m1051 \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, \dots, a_n (1ai1091 \le a_i \le 10^9) — Alice’s array.

The third line contains mm integers b1,b2,,bmb_1, b_2, \dots, b_m (1bi1091 \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.

输出格式

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

2
1 1
70
90
2 3
30 30
20 20 40
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.