题解:Codeforces Round 964 (Div. 4) B

B. Card Game

time limit per test: 2 seconds

memory limit per test: 256 megabytes

input: standard input

output: standard output


Suneet and Slavic play a card game. The rules of the game are as follows:

  • Each card has an integer value between 1 1 1 and 10 10 10.
  • Each player receives 2 2 2 cards which are face-down (so a player doesn’t know their cards).
  • The game is turn-based and consists exactly of two turns. In a round, both players pick a random unflipped card and flip it. The player who flipped a card with a strictly greater number wins the round. In case of equality, no one wins the round.
  • A player wins a game if he wins the most number of rounds (i.e. strictly greater than the other player). In case of equality, no one wins the game.

Since Suneet and Slavic aren’t best friends, you need to calculate the number of ways the game could happen that Suneet would end up as the winner.

For a better understanding, please check the notes section.

Input

The first line contains an integer t t t ( 1 ≤ t ≤ 1 0 4 1 \leq t \leq 10^4 1t104) — the number of test cases.

The first and only line of each test case contains 4 4 4 integers a 1 a_1 a1, a 2 a_2 a2, b 1 b_1 b1, b 2 b_2 b2 ( 1 ≤ a 1 , a 2 , b 1 , b 2 ≤ 10 1 \leq a_1, a_2, b_1, b_2 \leq 10 1a1,a2,b1,b210) where a 1 a_1 a1 and a 2 a_2 a2 represent the cards Suneet has, and b 1 b_1 b1 and b 2 b_2 b2 represent the cards Slavic has, respectively.

Output

For each test case, output a single integer — the number of games Suneet would win considering all possible games.

题意

Suneet和Slavic各有两张牌,他们将进行两轮游戏,每轮游戏掀开自己未掀开的牌中的任意一张

  • 若我方该轮掀开的牌比对方大,则我方获胜。
  • 若我方该轮掀开的牌比对方小,则对方获胜。
  • 若牌双方相同,则无人获胜。

求我方获胜次数比对方多的情况

Example

Input
5
3 8 2 6
1 1 1 1
10 10 2 2
1 1 10 10
3 8 7 2
Output
2
0
4
0
2

Note

Consider the first test case when Slavic starts with the cards that have the values 2 2 2 and 6 6 6, and Suneet starts with cards that have the values 3 3 3 and 8 8 8. The game could happen in 4 4 4 different ways:

  • Suneet flips 3 3 3 and Slavic flips 2 2 2. Suneet wins the first round. Then, Suneet flips 8 8 8 and Slavic flips 6 6 6. Suneet wins the second round as well. Since Suneet won 2 2 2 rounds, he wins the game.

  • Suneet flips 3 3 3 and Slavic flips 6 6 6. Slavic wins the first round. Then, Suneet flips 8 8 8 and Slavic flips 2 2 2. Suneet wins the second round. Nobody wins since both players won an equal amount of rounds.

  • Suneet flips 8 8 8 and Slavic flips 6 6 6. Suneet wins the first round. Then, Suneet flips 3 3 3 and Slavic flips 2 2 2. Suneet wins the second round as well. Since Suneet won 2 2 2 rounds, he wins the game.

  • Suneet flips 8 8 8 and Slavic flips 2 2 2. Suneet wins the first round. Then, Suneet flips 3 3 3 and Slavic flips 6 6 6. Slavic wins the round. Nobody wins since both players won an equal amount of rounds.

考虑第一个测试案例,当斯拉夫克开始时有牌值为 2 2 2 6 6 6 的牌,而苏尼特开始时有牌值为 3 3 3 8 8 8 的牌。游戏可能以 4 4 4 种不同的方式进行:

  • Suneet 翻 3 3 3 ,Slavic 翻 2 2 2 。Suneet 赢了第一轮。然后,Suneet 翻 8 8 8 ,Slavic 翻 6 6 6 。Suneet 同样赢得第二轮。由于 Suneet 赢了 2 2 2 个回合,所以他赢了这局棋。

  • Suneet 翻 3 3 3 ,Slavic 翻 6 6 6 。斯拉夫赢得第一轮。然后,Suneet 翻 8 8 8 ,Slavic 翻 2 2 2 。Suneet 赢第二轮。由于双方赢得的回合数相同,因此没有人获胜。

  • Suneet 翻转 8 8 8 ,Slavic 翻转 6 6 6 。Suneet 赢了第一轮。然后,Suneet 翻出 3 3 3 ,Slavic 翻出 2 2 2 。Suneet 同样赢得第二轮。由于 Suneet 赢了 2 2 2 个回合,他赢得了游戏。

  • Suneet 翻 8 8 8 ,Slavic 翻 2 2 2 。Suneet 赢了第一轮。然后,Suneet 翻出 3 3 3 ,Slavic 翻出 6 6 6 。斯拉夫赢得这一轮。由于双方赢得的回合数相同,因此没有人获胜。

题解

只要选定了我方一张牌和对方一张牌,另外两张牌也已经锁定了
因此:假设我有牌 a a a b b b ,对方有牌 c c c d d d
只要计算

  1. a a a c c c b b b d d d
  2. a a a d d d b b b c c c

两种的胜负情况
再乘 2 2 2(因为可以调换顺序)
然后输出就可以了

代码

#include <bits/stdc++.h>
#define int unsigned long long
#define INF 0x3f3f3f3f
#define all(x) x.begin(),x.end()

int t = 1;

void solve() {
    int a,b,c,d;
    std::cin >>a >> b >> c >> d;
    int ans = 0;
    int ans1 = 0,ans2 = 0;
    if((a > c && b >= d) || (a >= c && b > d)) ans += 2;
    if((a > d && b >= c) || (a >= d && b > c)) ans += 2;
    std::cout << ans << "\n";
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

    std::cin >> t;
    while(t--) solve();
    return 0;
}

转载自博客https://www.cnblogs.com/jiejiejiang2004/p/18347213
博主已同意,我就是博主

  • 12
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据提供的引用内容,Codeforces Round 511 (Div. 1)是一个比赛的名称。然而,引用内容中没有提供与这个比赛相关的具体信息或问题。因此,我无法回答关于Codeforces Round 511 (Div. 1)的问题。如果您有关于这个比赛的具体问题,请提供更多的信息,我将尽力回答。 #### 引用[.reference_title] - *1* [Codeforces Round 860 (Div. 2)题解](https://blog.csdn.net/qq_60653991/article/details/129802687)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Codeforces Round 867 (Div. 3)(A题到E题)](https://blog.csdn.net/wdgkd/article/details/130370975)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [Codeforces Round 872 (Div. 2)(前三道](https://blog.csdn.net/qq_68286180/article/details/130570952)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值