CF1681A 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
说明/提示
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.