codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1455C.md (2984B)


      1 Source: https://codeforces.com/problemset/problem/1455/C
      2 
      3 C. Ping-pong
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Alice and Bob play ping-pong with simplified rules.
     22 
     23 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.
     24 
     25 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.
     26 
     27 Alice has $x$ stamina and Bob has $y$. To hit the ball (while serving or returning) each player spends $1$ 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.
     28 
     29 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.
     30 
     31 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.
     32 
     33 Calculate the resulting number of Alice's and Bob's wins.
     34 
     35 Input
     36 
     37 The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of test cases.
     38 
     39 The first and only line of each test case contains two integers $x$ and $y$ ($1 \le x, y \le 10^6$) — Alice's and Bob's initial stamina.
     40 
     41 Output
     42 
     43 For each test case, print two integers — the resulting number of Alice's and Bob's wins, if both of them play optimally.
     44 
     45 Example
     46 
     47 Input
     48 
     49 ```
     50 3
     51 1 1
     52 2 1
     53 1 7
     54 ```
     55 
     56 Output
     57 
     58 ```
     59 0 1
     60 1 1
     61 0 7
     62 ```
     63 
     64 Note
     65 
     66 In the first test case, Alice serves the ball and spends $1$ stamina. Then Bob returns the ball and also spends $1$ 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 $0$ Alice's wins and $1$ Bob's wins.
     67 
     68 In the second test case, Alice serves the ball and spends $1$ 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 $1$ more stamina. This time, Bob returns the ball and spends $1$ 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 $1$ Alice's and $1$ Bob's win.
     69 
     70 In the third test case, Alice serves the ball and spends $1$ stamina. Bob returns the ball and spends $1$ 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 $6$ plays. Each time Alice can't return the ball and loses each play. The game is over with $0$ Alice's and $7$ Bob's wins.