#4469. Generalized Subtraction Game

0

Generalized Subtraction Game

Generalized Subtraction Game

题目描述

This is an 交互式任务(你的程序通过标准输入输出与裁判程序交互)。 你将得到整数 NN、LL 和 RR。
你与裁判进行以下博弈:

桌上有编号为 $1$ 到 $N$ 的 $N$ 张牌。
玩家交替执行以下操作:

选择整数对 (x,y)(x, y),满足 1≤x≤N1 \leq x \leq N、L≤y≤RL \leq y \leq R,且这 yy 张牌 x,x+1,…,x+y−1x, x+1, \dots, x+y-1 全部仍在桌上,然后从桌上移去牌 x,x+1,…,x+y−1x, x+1, \dots, x+y-1。

第一个无法执行该操作的玩家输,另一方赢。

选择先手或后手,并与裁判对弈以获胜。

输入格式

输出格式

提示

1≤N≤20001 \leq N \leq 2000 1≤L≤R≤N1 \leq L \leq R \leq N NN、LL 和 RR 为整数。This is an interactive task (where your program interacts with the judge's program via Standard Input and Output). Initially, receive NN, LL, and RR, given from the input in the following format: NN LL RR

First, you choose whether to go first or second. Print FirstFirst if you choose to go first, and SecondSecond 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)(x, y) that you choose in the operation in the following format. If there is no (x,y)(x, y) that you can choose, print (x,y)=(0,0)(x, y) = (0, 0) instead. xx yy

In the judge's turn, the judge print an integer pair (a,b)(a, b) in the following format: aa bb

Here, it is guaranteed that (a,b)(a, b) is of one of the following three kinds.

If (a,b)=(0,0)(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)(a, b) = (-1, -1): you have chosen an illegal (x,y)(x, y) or printed (0,0)(0, 0). In other words, you have lost the game. Otherwise: the judge has performed the operation with (x,y)=(a,b)(x,y) = (a,b). It is guaranteed that judge chooses valid (x,y)(x, y).

If the judge returns (a,b)=(0,0)(a,b)=(0,0) or (a,b)=(−1,−1)(a,b)=(-1,-1), the game has already ended. In that case, terminate the program immediately.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.The following is a sample interaction where N=6,L=1N = 6, L = 1, and R=2R = 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.

标签: AtCoder|abc278G

来源

AtCoder|abc278G