欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1999B.Card Game
Card Game
Suneet and Slavic play a card game. The rules of the game are as follows:
- Each card has an integer value between and .
- Each player receives 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 () — the number of test cases.
The first and only line of each test case contains integers , , , () where and represent the cards Suneet has, and and 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.
Note
Consider the first test case when Slavic starts with the cards that have the values and , and Suneet starts with cards that have the values and . The game could happen in different ways:
- Suneet flips and Slavic flips . Suneet wins the first round. Then, Suneet flips and Slavic flips . Suneet wins the second round as well. Since Suneet won rounds, he wins the game.
- Suneet flips and Slavic flips . Slavic wins the first round. Then, Suneet flips and Slavic flips . Suneet wins the second round. Nobody wins since both players won an equal amount of rounds.
- Suneet flips and Slavic flips . Suneet wins the first round. Then, Suneet flips and Slavic flips . Suneet wins the second round as well. Since Suneet won rounds, he wins the game.
- Suneet flips and Slavic flips . Suneet wins the first round. Then, Suneet flips and Slavic flips . Slavic wins the round. Nobody wins since both players won an equal amount of rounds.
Samples
5
3 8 2 6
1 1 1 1
10 10 2 2
1 1 10 10
3 8 7 2
2
0
4
0
2
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |