欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1455C.Ping-pong
Ping-pong
Alice and Bob play ping-pong with simplified rules.
During the game, the player serving the ball commences a play. The server strikes the ball then the receiver makes a return by hitting the ball back. Thereafter, the server and receiver must alternately make a return until one of them doesn't make a return.
The one who doesn't make a return loses this play. The winner of the play commences the next play. Alice starts the first play.
Alice has stamina and Bob has . To hit the ball (while serving or returning) each player spends stamina, so if they don't have any stamina, they can't return the ball (and lose the play) or can't serve the ball (in this case, the other player serves the ball instead). If both players run out of stamina, the game is over.
Sometimes, it's strategically optimal not to return the ball, lose the current play, but save the stamina. On the contrary, when the server commences a play, they have to hit the ball, if they have some stamina left.
Both Alice and Bob play optimally and want to, firstly, maximize their number of wins and, secondly, minimize the number of wins of their opponent.
Calculate the resulting number of Alice's and Bob's wins.
Input
The first line contains a single integer () — the number of test cases.
The first and only line of each test case contains two integers and () — Alice's and Bob's initial stamina.
Output
For each test case, print two integers — the resulting number of Alice's and Bob's wins, if both of them play optimally.
Note
In the first test case, Alice serves the ball and spends stamina. Then Bob returns the ball and also spends stamina. Alice can't return the ball since she has no stamina left and loses the play. Both of them ran out of stamina, so the game is over with Alice's wins and Bob's wins.
In the second test case, Alice serves the ball and spends stamina. Bob decides not to return the ball — he loses the play but saves stamina. Alice, as the winner of the last play, serves the ball in the next play and spends more stamina. This time, Bob returns the ball and spends stamina. Alice doesn't have any stamina left, so she can't return the ball and loses the play. Both of them ran out of stamina, so the game is over with Alice's and Bob's win.
In the third test case, Alice serves the ball and spends stamina. Bob returns the ball and spends stamina. Alice ran out of stamina, so she can't return the ball and loses the play. Bob, as a winner, serves the ball in the next plays. Each time Alice can't return the ball and loses each play. The game is over with Alice's and Bob's wins.
Samples
3
1 1
2 1
1 7
0 1
1 1
0 7
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |