#abc278g. G - Generalized Subtraction Game
G - Generalized Subtraction Game
Score : points
问题描述
这是一个交互式任务(其中您的程序通过标准输入和输出与评委程序进行互动)。
给定整数 、 和 ,您将与评委进行如下游戏:
桌子上放置了编号为 到 的 张卡片。
玩家交替执行以下操作:
- 选择满足条件的整数对 ,即 ,,且卡片 均仍在桌子上,然后从桌子上移除卡片 。
首先无法执行操作的玩家输掉比赛,而另一名玩家获胜。
请选择先手或后手,并与评委进行游戏以求获胜。
以上为通义千问 qwen-max 翻译,仅供参考。
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 , , and .
You play the following game against the judge:
There are cards numbered through on the table.
The players alternately perform the following operation:
- choose an integer pair satisfying , such that all of the cards remain on the table, and remove cards 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
- , , and 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 , , and , given from the input in the following format:
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 that you choose in the operation in the following format. If there is no that you can choose, print instead.
In the judge's turn, the judge print an integer pair in the following format:
Here, it is guaranteed that is of one of the following three kinds.
-
If : the judge is unable to perform the operation. In other words, you have won the game.
-
If : you have chosen an illegal or printed . In other words, you have lost the game.
-
Otherwise: the judge has performed the operation with . It is guaranteed that judge chooses valid .
If the judge returns or , 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 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 , and .
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. |
update @ 2024/3/10 11:43:19