CF1455C.Ping-pong

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 xx stamina and Bob has yy. To hit the ball (while serving or returning) each player spends 11 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.

Alice 和 Bob 以简化规则进行乒乓球比赛。

比赛中,发球方首先发起一回合。发球方击球后,接球方需回击(将球打回)。此后,发球方与接球方必须交替回击,直至其中一方未能成功回击为止。

未能回击的一方输掉该回合。该回合的获胜者发起下一回合。第一回合由 Alice 发球。

Alice 拥有 xx 点体力,Bob 拥有 yy 点体力。每次击球(无论是发球还是回击),玩家均消耗 11 点体力;因此,若某玩家体力耗尽,则无法回击(从而输掉该回合),也无法发球(此时由对方代替发球)。若双方体力同时耗尽,则比赛结束。

有时,从策略角度考虑,主动放弃回击、输掉当前回合以节省体力,反而是最优选择;但当某玩家作为发球方发起一回合时,只要其尚有体力,就必须击球(即不能主动放弃发球)。

Alice 和 Bob 均采取最优策略:首要目标是最大化自己的获胜回合数,次要目标是最小化对手的获胜回合数。

请计算最终 Alice 和 Bob 各自获胜的回合数。

输入格式

The first line contains a single integer tt (1≤t≤1041 \le t \le 10^4) — the number of test cases.

The first and only line of each test case contains two integers xx and yy (1≤x,y≤1061 \le x, y \le 10^6) — Alice's and Bob's initial stamina.

第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)—— 测试用例的数量。

每个测试用例仅有一行,包含两个整数 xx 和 yy(1≤x,y≤1061 \le x, y \le 10^6)—— 分别表示爱丽丝和鲍勃的初始体力值。

输出格式

For each test case, print two integers — the resulting number of Alice's and Bob's wins, if both of them play optimally.

对于每个测试用例,输出两个整数——如果 Alice 和 Bob 均采用最优策略进行游戏,则 Alice 和 Bob 的获胜次数。

输入输出样例

  • 输入#1

    3
    1 1
    2 1
    1 7

    输出#1

    0 1
    1 1
    0 7

说明/提示

In the first test case, Alice serves the ball and spends 11 stamina. Then Bob returns the ball and also spends 11 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 00 Alice's wins and 11 Bob's wins.

In the second test case, Alice serves the ball and spends 11 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 11 more stamina. This time, Bob returns the ball and spends 11 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 11 Alice's and 11 Bob's win.

In the third test case, Alice serves the ball and spends 11 stamina. Bob returns the ball and spends 11 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 66 plays. Each time Alice can't return the ball and loses each play. The game is over with 00 Alice's and 77 Bob's wins.

在第一个测试用例中,Alice 发球并消耗 11 点体力。随后 Bob 回球,同样消耗 11 点体力。Alice 此时已无剩余体力,无法回球,因而输掉这一回合。此时双方体力均已耗尽,因此比赛结束,Alice 获胜 00 次,Bob 获胜 11 次。

在第二个测试用例中,Alice 发球并消耗 11 点体力。Bob 选择不回球——他输掉这一回合,但保留了体力。由于 Alice 是上一回合的获胜者,她将在下一回合发球,并再消耗 11 点体力。这一次,Bob 回球并消耗 11 点体力。Alice 此时已无剩余体力,无法回球,因而输掉这一回合。此时双方体力均已耗尽,因此比赛结束,Alice 和 Bob 各获胜 11 次。

在第三个测试用例中,Alice 发球并消耗 11 点体力。Bob 回球并消耗 11 点体力。Alice 体力已耗尽,无法回球,因而输掉这一回合。作为获胜方,Bob 在接下来的 66 个回合中连续发球。每回合 Alice 均无法回球,因而连续输掉这 66 个回合。最终比赛结束,Alice 获胜 00 次,Bob 获胜 77 次。

输入解题思路,AI测评打分。不知道怎么写?

首页