No.3661 Grid Paint Game
タグ : / 解いたユーザー数 65
作問者 :
sepa38
くらげ
Problem Statement
There is a grid with $H$ rows and $W$ columns. Initially, no cell is painted.
sepa and ryota play a game using this grid.
With sepa moving first and ryota moving second, they alternately perform one of the following operations.
- Choose an integer $i$ satisfying $1 \leq i \leq H$ that has not yet been chosen during this game. Then choose one color, black or white, and repaint all cells in row $i$ of the grid with that color.
- Choose an integer $j$ satisfying $H+1 \leq j \leq H+W$ that has not yet been chosen during this game. Then choose one color, black or white, and repaint all cells in column $j-H$ of the grid with that color.
The game ends when the player whose turn it is cannot perform an operation.
If the number of black cells minus the number of white cells at the end of the game is at least $0$, sepa wins; otherwise, ryota wins.
Determine who wins when both players play optimally.
You are given $T$ test cases; solve each of them.
Constraints
- $1 \leq T \leq 10^5$
- $1 \leq H,W \leq 10^9$
- All input values are integers.
Input
The input is given from standard input in the following format.
$T$
$\mathrm{case}_1$
$\mathrm{case}_2$
$\vdots$
$\mathrm{case}_T$
Each test case is given in the following format.
$H$ $W$
Output
Print $T$ lines.
On line $k$, for the $k$-th test case, print sepa if sepa wins, and ryota if ryota wins.
Sample
Sample 1
Input
3 1 1 2 3 1000000000 1000000000
Output
ryota sepa ryota
In the $1$-st test case, whichever integer sepa chooses, ryota can win by choosing the remaining one and repainting the cell white.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。