CF1895E.Infinite Card Game
提高+/省选-
通过率:0%
时间限制:3.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Monocarp and Bicarp are playing a card game. Each card has two parameters: an attack value and a defence value. A card s beats another card t if the attack of s is strictly greater than the defence of t.
Monocarp has n cards, the i-th of them has an attack value of axi and a defence value of ayi. Bicarp has m cards, the j-th of them has an attack value of bxj and a defence value of byj.
On the first move, Monocarp chooses one of his cards and plays it. Bicarp has to respond with his own card that beats that card. After that, Monocarp has to respond with a card that beats Bicarp's card. After that, it's Bicarp's turn, and so forth.
After a card is beaten, it returns to the hand of the player who played it. It implies that each player always has the same set of cards to play as at the start of the game. The game ends when the current player has no cards that beat the card which their opponent just played, and the current player loses.
If the game lasts for 100500 moves, it's declared a draw.
Both Monocarp and Bicarp play optimally. That is, if a player has a winning strategy regardless of his opponent's moves, he plays for a win. Otherwise, if he has a drawing strategy, he plays for a draw.
You are asked to calculate three values:
- the number of Monocarp's starting moves that result in a win for Monocarp;
- the number of Monocarp's starting moves that result in a draw;
- the number of Monocarp's starting moves that result in a win for Bicarp.
Monocarp 和 Bicarp 正在进行一场卡牌游戏。每张卡牌有两个参数:攻击力和防御力。卡牌 s 击败卡牌 t,当且仅当 s 的攻击力严格大于 t 的防御力。
Monocarp 拥有 n 张卡牌,其中第 i 张卡牌的攻击力为 axi,防御力为 ayi;Bicarp 拥有 m 张卡牌,其中第 j 张卡牌的攻击力为 bxj,防御力为 byj。
游戏的第一步由 Monocarp 执行:他选择自己手中的一张卡牌打出。随后 Bicarp 必须用一张能击败该卡牌的自己的卡牌进行回应。接着 Monocarp 必须用一张能击败 Bicarp 刚打出的卡牌的自己的卡牌进行回应。之后轮到 Bicarp,如此交替进行。
一张卡牌被击败后,会回到其原主人的手牌中。这意味着每位玩家在整场游戏中始终拥有与游戏开始时完全相同的卡牌集合。当轮到某位玩家行动时,若他手中没有任何卡牌能击败对手上一轮刚打出的卡牌,则游戏立即结束,该玩家判负。
若游戏持续了 100500 回合,则判定为平局。
Monocarp 和 Bicarp 均以最优策略进行游戏:即若某位玩家存在一种无论对手如何应对均能获胜的策略,则他将选择该必胜策略;否则,若他存在一种能确保平局的策略,则他将选择该必平策略。
你需要计算以下三个值:
- Monocarp 的起始出牌中,能导致 Monocarp 获胜的方案数;
- Monocarp 的起始出牌中,能导致平局的方案数;
- Monocarp 的起始出牌中,能导致 Bicarp 获胜的方案数。
输入格式
The first line contains a single integer t (1≤t≤104) — the number of test cases.
The first line of each test case contains an integer n (1≤n≤3⋅105) — the number of cards Monocarp has.
The second line contains n integers ax1,ax2,…,axn (1≤axi≤106) — the attack values of Monocarp's cards.
The third line contains n integers ay1,ay2,…,ayn (1≤ayi≤106) — the defence values of Monocarp's cards.
The fourth line contains a single integer m (1≤m≤3⋅105) — the number of cards Bicarp has.
The fifth line contains m integers bx1,bx2,…,bxm (1≤bxj≤106) — the attack values of Bicarp's cards.
The sixth line contains m integers by1,by2,…,bym (1≤byj≤106) — the defence values of Bicarp's cards.
Additional constraints on the input: the sum of n over all test cases doesn't exceed 3⋅105, the sum of m over all test cases doesn't exceed 3⋅105.
第一行包含一个整数 t(1≤t≤104)—— 测试用例的数量。
每个测试用例的第一行包含一个整数 n(1≤n≤3⋅105)—— Monocarp 拥有的卡牌数量。
第二行包含 n 个整数 ax1,ax2,…,axn(1≤axi≤106)—— Monocarp 卡牌的攻击力值。
第三行包含 n 个整数 ay1,ay2,…,ayn(1≤ayi≤106)—— Monocarp 卡牌的防御力值。
第四行包含一个整数 m(1≤m≤3⋅105)—— Bicarp 拥有的卡牌数量。
第五行包含 m 个整数 bx1,bx2,…,bxm(1≤bxj≤106)—— Bicarp 卡牌的攻击力值。
第六行包含 m 个整数 by1,by2,…,bym(1≤byj≤106)—— Bicarp 卡牌的防御力值。
输入的额外约束:所有测试用例中 n 的总和不超过 3⋅105,所有测试用例中 m 的总和不超过 3⋅105。
输出格式
For each test case, print three integers:
- the number of Monocarp's starting moves that result in a win for Monocarp;
- the number of Monocarp's starting moves that result in a draw;
- the number of Monocarp's starting moves that result in a win for Bicarp.
对每个测试用例,输出三个整数:
- Monocarp 的起始操作中导致 Monocarp 获胜的数量;
- Monocarp 的起始操作中导致平局的数量;
- Monocarp 的起始操作中导致 Bicarp 获胜的数量。
输入输出样例
输入#1
3 3 8 7 4 7 1 10 2 8 4 5 10 9 8 8 5 5 5 4 4 1 4 2 7 5 2 8 9 7 1 9 10 9 8 7 6 5 5 4 3 2 1 7 1 6 7 5 8 8 4 9 6 1 10 5 1 10 5
输出#1
1 1 1 2 4 3 0 1 0
输入解题思路,AI测评打分。不知道怎么写?