102786: [AtCoder]ABC278 G - Generalized Subtraction Game
Description
Score : $600$ points
Problem Statement
This is an interactive task (where your program interacts with the judge's program via Standard Input and Output).
You are given integers $N$, $L$, and $R$.
You play the following game against the judge:
There are $N$ cards numbered $1$ through $N$ on the table.
The players alternately perform the following operation:
- choose an integer pair $(x, y)$ satisfying $1 \leq x \leq N$, $L \leq y \leq R$ such that all of the $y$ cards $x, x+1, \dots, x+y-1$ remain on the table, and remove cards $x, x+1, \dots, x+y-1$ from the table.
The first player to become unable to perform the operation loses, and the other player wins.
Choose whether to go first or second, and play the game against the judge to win.
Constraints
- $1 \leq N \leq 2000$
- $1 \leq L \leq R \leq N$
- $N$, $L$, and $R$ are integers.
Input and Output
This is an interactive task (where your program interacts with the judge's program via Standard Input and Output).
Initially, receive $N$, $L$, and $R$, given from the input in the following format:
$N$ $L$ $R$
First, you choose whether to go first or second. Print First
if you choose to go first, and Second
if you choose to go second.
Then, the game immediately starts. If you choose to go first, the judge goes second, and vice versa. You are to interact with the judge via input and output until the game ends to win the game.
In your turn, print an integer pair $(x, y)$ that you choose in the operation in the following format. If there is no $(x, y)$ that you can choose, print $(x, y) = (0, 0)$ instead.
$x$ $y$
In the judge's turn, the judge print an integer pair $(a, b)$ in the following format:
$a$ $b$
Here, it is guaranteed that $(a, b)$ is of one of the following three kinds.
- If $(a, b) = (0, 0)$: the judge is unable to perform the operation. In other words, you have won the game.
- If $(a, b) = (-1, -1)$: you have chosen an illegal $(x, y)$ or printed $(0, 0)$. In other words, you have lost the game.
- Otherwise: the judge has performed the operation with $(x,y) = (a,b)$. It is guaranteed that judge chooses valid $(x, y)$.
If the judge returns $(a,b)=(0,0)$ or $(a,b)=(-1,-1)$, the game has already ended. In that case, terminate the program immediately.
Notes
- After each output, add a newline and then flush Standard Output. Otherwise, you may get a TLE
Input
题意翻译
- 给定 $n$,$l$,$r$ 三个数,你需要和交互器博弈。 - 有一个长度为 $n$ 的区间,你和交互器轮流操作,其中先后手由你自己决定。 - 每次操作,操作的一方选择一个没有被染黑并且长度在 $l$ 和 $r$ 之间的区间,把它染黑。 - 无法操作的一方寄了,另一方获胜。 - 每次你操作要输出两个数 $a$ 和 $b$,表示你选择了区间 $[a,a+b-1]$。 - 每次交互器操作会给你两个数 $a$ 和 $b$,表示交互器选择了 $[a,a+b-1]$,若 $a=b=0$ 则表示你获胜,如果 $a=b=-1$ 则表示你寄了。Output
问题描述
这是一个交互式任务(您的程序通过标准输入和输出与裁判程序交互)。
您将获得整数$N$,$L$和$R$。
桌子上放置着编号为$1$到$N$的$N$张卡片。
玩家轮流执行以下操作:
- 选择一个满足$1 \leq x \leq N$,$L \leq y \leq R$的整数对$(x, y)$,使得卡片$x$,$x+1$,$\dots$,$x+y-1$都在桌子上,然后从桌子上移除卡片$x$,$x+1$,$\dots$,$x+y-1$。
第一个无法执行操作的玩家输掉比赛,另一个玩家赢得比赛。
选择先手或后手,与裁判进行游戏以赢得比赛。
约束条件
- $1 \leq N \leq 2000$
- $1 \leq L \leq R \leq N$
- $N$,$L$和$R$为整数。
输入和输出
这是一个交互式任务(您的程序通过标准输入和输出与裁判程序交互)。
首先,从输入中以以下格式接收$N$,$L$和$R$:
$N$ $L$ $R$
首先,您选择先手或后手。如果您选择先手,请打印First
;如果您选择后手,请打印Second
。
然后,游戏立即开始。如果您选择先手,则裁判后手,反之亦然。您需要通过输入和输出与裁判进行交互,直到游戏结束才能赢得比赛。
轮到您时,以以下格式打印您在操作中选择的整数对$(x, y)$。如果无法选择$(x, y)$,则打印$(x, y) = (0, 0)$代替。
$x$ $y$
轮到裁判时,裁判以以下格式打印整数对$(a, b)$:
$a$ $b$
在这里,可以保证$(a, b)$是以下三种类型之一。
- 如果$(a, b) = (0, 0)$:裁判无法执行操作。换句话说,您已经赢得了比赛。
- 如果$(a, b) = (-1, -1)$:您选择了一个非法的$(x, y)$或打印了$(0, 0)$。换句话说,您已经输掉了比赛。
- 否则:裁判已经执行了操作$(x, y) = (a,b)$。可以保证裁判选择有效的$(x, y)$。
如果裁判返回$(a,b)=(0,0)$或$(a,b)=(-1,-1)$,比赛已经结束。在这种情况下,请立