問題一覧 > 通常問題

No.3120 Lower Nim

レベル : / AI推定難易度 : 2000 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / リアクティブ問題 (詳しくはこちら)
タグ : (AC するまで非表示) / 解いたユーザー数 38
作問者 : Nzt3 / テスター : ponjuice kenken714 Naru820
お気に入りにしたユーザー ProblemId : 12124 / 自分の提出
問題文最終更新日: 2025-04-18 21:10:48
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
CPCTF 2025 : PPC (順位表) の他の問題:

Problem Statement

This problem is a reactive problem.

There is an integer sequence $A$ of length $N$.

You and the judge take turns alternately. You may choose whether to go first or second.

On a turn, the player performs the following series of operations. Initially, $K=10^{100}$.

  • Choose an integer $x \ (1 \le x \le K)$.
  • Choose $i \ (1 \le i \le N)$ satisfying $x \le A_i$.
  • Update $A_i \leftarrow A_i - x,\ K \leftarrow x$.

The player who can no longer make a valid move loses, and the player who did not lose wins.

Act appropriately and win.

Constraints

  • $1 \le N \le 10^4$
  • $1 \le A_i \le 10^4 \ (1\le i \le N)$
  • $\sum _{i=1}^{N}A_i \le 10^4$

Input and Output

First, an integer $N$ is given.

$N$

Next, the integer sequence $A$ is given on $1$ line, separated by spaces.

$A_1$ $A_2$ $\ldots$ $A_N$

Then, choose whether to go first or second, and print a string $s$ representing your choice on $1$ line. Print First to go first, or Second to go second.

$s$

After this, the turns alternate.

Judge's Turn

The $i,x$ chosen by the judge in its operation are given on $1$ line, separated by a space.

$i$ $x$

Then, an integer $\mathrm{ret}$ representing the state of the problem is given.

$\mathrm{ret}$
  • If $\mathrm{ret} = 0$, the game continues.
  • If $\mathrm{ret} = -1$, it means that you lose. Terminate your program.
Your Turn

Print the $i,x$ you chose in your operation on $1$ line, separated by a space.

$i$ $x$

Then, an integer $\mathrm{ret}$ representing the state of the problem is given.

$\mathrm{ret}$
  • If $\mathrm{ret} = 1$, it means that you have won. Terminate your program.
  • If $\mathrm{ret} = 0$, the game continues.
  • If $\mathrm{ret} = -1$, it means that you lose. Terminate your program.

Notes

  • If it is determined that you will lose when the judge plays optimally, $\mathrm{ret} = -1$ may be given before the game ends.
  • Flush the output each time you print.
  • If your output format is incorrect or does not satisfy the constraints, the judge result may be undefined.

Sample

InputOutputExplanation
2$N=2$
1 2$A=(1,2)$
FirstYou chose to go first.
2 1You operated with $i=2,x=1$. It is updated as $k\leftarrow 1$.
0The game continues.
1 1The judge operated with $i=1,x=1$.
0The game continues.
2 1You operated with $i=2,x=1$.
1Now $A=(0,0)$, and no more operations are possible. You won.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。