AtCoder Beginner Contest 278
G
Generalized Subtraction Game
AtCoder
⌀ 2533
原题
← Ex→
翻译中…

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.

翻译中…

Note

翻译中…
  • After each output, add a newline and then flush Standard Output. Otherwise, you may get a TLE verdict.
  • If an invalid output is printed during the interaction, or if the program terminates halfway, the verdict will be indeterminate. Especially, note that if a runtime error occurs during the execution of the program, you may get a WA or TLE verdict instead of a RE verdict.
  • Terminate the program immediately after the game ends. Otherwise, the verdict will be indeterminate.
翻译中…

Sample Interaction

翻译中…

The following is a sample interaction where $N = 6, L = 1$, and $R = 2$.

翻译中…
Input Output Description
6 1 2 Initially, you are given integers $N$, $L$, and $R$.
First You choose to go first and start the game.
2 1 $(x, y) = (2, 1)$ is chosen to remove card $2$.
3 2 $(x, y) = (3, 2)$ is chosen to remove cards $3, 4$.
6 1 $(x, y) = (6, 1)$ is chosen to remove card $6$.
5 1 $(x, y) = (5, 1)$ is chosen to remove card $5$.
1 1 $(x, y) = (1, 1)$ is chosen to remove card $1$.
0 0 The judge is unable to perform the operation, so you win.
翻译中…
题目信息
题号
abc278_g
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。