CF1455C.Ping-pong

普及/提高-

通过率:0%

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.

输入格式

The first line contains a single integer tt ( 1t1041 \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 ( 1x,y1061 \le x, y \le 10^6 ) — Alice's and Bob's initial stamina.

输出格式

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

输入输出样例

  • 输入#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.

首页