309452: CF1681A. Game with Cards

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Game with Cards

题意翻译

### 题目描述 爱丽丝和鲍勃一起玩一个纸牌游戏,爱丽丝有$n$张牌,鲍勃有$m$张牌,每张牌上有一个数值。 在游戏的第一回合,由任意一方玩家先手打出手中的任意一张牌,然后另一个玩家需从手中的牌中打出数值一张比此玩家打出的牌更大的牌,若在某一回合,某方无法打出,则视为此方输掉游戏。 例如:爱丽丝的手牌是$[10,5,3,8]$,鲍勃的手牌是$[6,11,6]$,举个栗子,游戏过程可能如下: - 爱丽丝选择卡牌$5$并打出它。 - 鲍勃选择卡牌$6$并打出它。 - 爱丽丝选择卡牌$10$并打出它。 - 鲍勃选择卡牌11并打出它。 - 爱丽丝可以选择她的任何卡牌,使其数字大于$11$,但她没有这样的牌,所以她输了。 现在,题目要求你回答两个问题: $1.$如果爱丽丝是先手玩家,谁赢了? $2.$如果鲍勃是先手玩家,谁赢了? ### 输入格式 第一行一个整数$t(1\leqslant t \leqslant1000)$,表示测试样例的数量。 每组测试样例第一行一个整数$n(1\leqslant n \leqslant50)$,表示爱丽丝拥有卡牌的数量。 第二行$n$个整数$a_i(1\leqslant a_i \leqslant50)$,表示爱丽丝的手牌上的整数。 第三行一个整数$m(1\leqslant m \leqslant50)$,表示鲍勃拥有卡牌的数量。 第四行$m$个整数$b_i(1\leqslant b_i \leqslant50)$,表示鲍勃的手牌上的整数。 ### 输出格式 每组测试样例输出两行,分别表示问题$1,2$的答案。 Translated by Code_AC 2022.5.31

题目描述

Alice and Bob play a game. Alice has $ n $ cards, the $ i $ -th of them has the integer $ a_i $ written on it. Bob has $ m $ cards, the $ j $ -th of them has the integer $ b_j $ written on it. On the first turn of the game, the first player chooses one of his/her cards and puts it on the table (plays it). On the second turn, the second player chooses one of his/her cards such that the integer on it is greater than the integer on the card played on the first turn, and plays it. On the third turn, the first player chooses one of his/her cards such that the integer on it is greater than the integer on the card played on the second turn, and plays it, and so on — the players take turns, and each player has to choose one of his/her cards with greater integer than the card played by the other player on the last turn. If some player cannot make a turn, he/she loses. For example, if Alice has $ 4 $ cards with numbers $ [10, 5, 3, 8] $ , and Bob has $ 3 $ cards with numbers $ [6, 11, 6] $ , the game may go as follows: - Alice can choose any of her cards. She chooses the card with integer $ 5 $ and plays it. - Bob can choose any of his cards with number greater than $ 5 $ . He chooses a card with integer $ 6 $ and plays it. - Alice can choose any of her cards with number greater than $ 6 $ . She chooses the card with integer $ 10 $ and plays it. - Bob can choose any of his cards with number greater than $ 10 $ . He chooses a card with integer $ 11 $ and plays it. - Alice can choose any of her cards with number greater than $ 11 $ , but she has no such cards, so she loses. Both Alice and Bob play optimally (if a player is able to win the game no matter how the other player plays, the former player will definitely win the game). You have to answer two questions: - who wins if Alice is the first player? - who wins if Bob is the first player?

输入输出格式

输入格式


The first line contains one integer $ t $ ( $ 1 \le t \le 1000 $ ) — the number of test cases. Each test case consists of four lines. The first line of a test case contains one integer $ n $ ( $ 1 \le n \le 50 $ ) — the number of cards Alice has. The second line contains $ n $ integers $ a_1, a_2, \dots, a_n $ ( $ 1 \le a_i \le 50 $ ) — the numbers written on the cards that Alice has. The third line contains one integer $ m $ ( $ 1 \le m \le 50 $ ) — the number of Bob's cards. The fourth line contains $ m $ integers $ b_1, b_2, \dots, b_m $ ( $ 1 \le b_i \le 50 $ ) — the numbers on Bob's cards.

输出格式


For each test case, print two lines. The first line should be Alice if Alice wins when she is the first player; otherwise, the first line should be Bob. The second line should contain the name of the winner if Bob is the first player, in the same format.

输入输出样例

输入样例 #1

4
1
6
2
6 8
4
1 3 3 7
2
4 2
1
50
2
25 50
10
1 2 3 4 5 6 7 8 9 10
2
5 15

输出样例 #1

Bob
Bob
Alice
Alice
Alice
Bob
Bob
Bob

说明

Let's consider the first test case of the example. Alice has one card with integer $ 6 $ , Bob has two cards with numbers $ [6, 8] $ . If Alice is the first player, she has to play the card with number $ 6 $ . Bob then has to play the card with number $ 8 $ . Alice has no cards left, so she loses. If Bob is the first player, then no matter which of his cards he chooses on the first turn, Alice won't be able to play her card on the second turn, so she will lose.

Input

题意翻译

### 题目描述 爱丽丝和鲍勃一起玩一个纸牌游戏,爱丽丝有$n$张牌,鲍勃有$m$张牌,每张牌上有一个数值。 在游戏的第一回合,由任意一方玩家先手打出手中的任意一张牌,然后另一个玩家需从手中的牌中打出数值一张比此玩家打出的牌更大的牌,若在某一回合,某方无法打出,则视为此方输掉游戏。 例如:爱丽丝的手牌是$[10,5,3,8]$,鲍勃的手牌是$[6,11,6]$,举个栗子,游戏过程可能如下: - 爱丽丝选择卡牌$5$并打出它。 - 鲍勃选择卡牌$6$并打出它。 - 爱丽丝选择卡牌$10$并打出它。 - 鲍勃选择卡牌11并打出它。 - 爱丽丝可以选择她的任何卡牌,使其数字大于$11$,但她没有这样的牌,所以她输了。 现在,题目要求你回答两个问题: $1.$如果爱丽丝是先手玩家,谁赢了? $2.$如果鲍勃是先手玩家,谁赢了? ### 输入格式 第一行一个整数$t(1\leqslant t \leqslant1000)$,表示测试样例的数量。 每组测试样例第一行一个整数$n(1\leqslant n \leqslant50)$,表示爱丽丝拥有卡牌的数量。 第二行$n$个整数$a_i(1\leqslant a_i \leqslant50)$,表示爱丽丝的手牌上的整数。 第三行一个整数$m(1\leqslant m \leqslant50)$,表示鲍勃拥有卡牌的数量。 第四行$m$个整数$b_i(1\leqslant b_i \leqslant50)$,表示鲍勃的手牌上的整数。 ### 输出格式 每组测试样例输出两行,分别表示问题$1,2$的答案。 Translated by Code_AC 2022.5.31

加入题单

算法标签: