第 231 场 AtCoder Regular Contest
D
选择你的角色
Choose Your Role
AtCoder
⌀ 2437
原题
← CE →

选择你的角色AI (CI翻译)

Problem Statement

题目描述

AI (CI翻译)

This is an interactive problem (where your program interacts with the judge system via Standard Input and Output).

这是一个交互题(你的程序通过标准输入和标准输出与评测系统进行交互)。AI (CI翻译)

There are $N$ piles numbered from $1$ to $N$. Each pile has $N - 1$ stones.

有 $N$ 堆编号为 $1$ 至 $N$ 的石子。每堆有 $N - 1$ 个石子。AI (CI翻译)

Consider a game played by the first player and the second player using these. In the game, the players take turns alternately, starting with the first player.

考虑先手玩家和后手玩家使用这些石堆进行的游戏。在游戏中,双方轮流行动,由先手玩家开始。AI (CI翻译)

  • The first player chooses one pile that has one or more stones, and removes between $1$ and $K$ stones, inclusive, from it.
  • The second player chooses between $1$ and $K$ piles, inclusive, each of which has one or more stones, and removes one stone from each of them.
  • 先手玩家选择一堆有一个或多个石子的石堆,并从中取出 $1$ 至 $K$ 个石子(包含 $1$ 和 $K$)。
  • 后手玩家选择 $1$ 至 $K$ 堆石子(包含 $1$ 和 $K$),每一堆都必须有一个或多个石子,然后从所选的每一堆中取出一个石子。
AI (CI翻译)

The player who first becomes unable to make a move loses. You will play this game against the judge. First, declare to the judge whether you will be the first player or the second player, and then play the game.

无法行动的玩家输掉游戏。你将与评测系统进行这场游戏。首先,向评测系统声明你将作为先手玩家还是后手玩家,然后进行游戏。AI (CI翻译)

Constraints

约束条件

AI (CI翻译)
  • $2 \leq N \leq 200$
  • $1 \leq K \leq N$
  • All input values are integers.
  • $2 \leq N \leq 200$
  • $1 \leq K \leq N$
  • 所有输入值均为整数。
AI (CI翻译)

Input and Output

输入与输出

AI (CI翻译)

This is an interactive problem (where your program interacts with the judge system via Standard Input and Output).

这是一个交互题(你的程序通过标准输入和标准输出与评测系统进行交互)。AI (CI翻译)

First, $N$ and $K$ are given in the following format; receive them from Standard Input.

首先,按照以下格式给出 $N$ 和 $K$;请从标准输入中读入它们。AI (CI翻译)

N K

N K
AI (CI翻译)

When playing as the first player
作为先手玩家时
AI (CI翻译)
  • First, output First followed by a newline.
  • Then, repeat the following interaction until the game ends.
  • First, output your move as the first player. If you remove $j$ stones from pile $i$, output $i$ and $j$ in this order, separated by a space, followed by a newline.
    • Next, receive the judge's move as the second player. First, receive an integer $k$. It means the following.
    • $k = -1$: This indicates that you have been judged as incorrect for this problem. Terminate your program immediately.
      • $k = 0$: This indicates that you have been judged as correct for this problem. Terminate your program immediately.
      • $k > 0$: Subsequently, $k$ integers $a_1, a_2, \cdots, a_k$ are given, separated by spaces. This indicates that the second player removes one stone from each of piles $a_1, a_2, \cdots, a_k$.
  • 首先,输出 First,并在末尾输出换行。
  • 然后,重复以下交互过程,直到游戏结束。
  • 首先,输出你作为先手玩家的操作。如果从第 $i$ 堆取出 $j$ 个石子,则按此顺序输出 $i$ 和 $j$,二者之间以空格分隔,并在末尾输出换行。
    • 接下来,接收评测系统作为后手玩家的操作。首先,接收一个整数 $k$。其含义如下。
    • $k = -1$:这表示你在本题中被判定为错误。立即终止程序。
      • $k = 0$:这表示你在本题中被判定为正确。立即终止程序。
      • $k > 0$:接下来会给出 $k$ 个以空格分隔的整数 $a_1, a_2, \cdots, a_k$。这表示后手玩家从第 $a_1, a_2, \cdots, a_k$ 堆中各取出一个石子。
AI (CI翻译)
When playing as the second player
作为后手玩家时
AI (CI翻译)
  • First, output Second followed by a newline.
  • Then, repeat the following interaction until the game ends.
  • First, receive the judge's move as the first player. Receive two integers $i$ and $j$. They mean the following.
    • $i = -1$: In this case, $j = -1$. This indicates that you have been judged as incorrect for this problem. Terminate your program immediately.
      • $i = 0$: In this case, $j = 0$. This indicates that you have been judged as correct for this problem. Terminate your program immediately.
      • $i > 0$: This indicates that the first player removed $j$ stones from pile $i$.
    • Next, output your move as the second player. If you remove one stone from each of piles $a_1, a_2, \cdots, a_k$, first output $k$ followed by a newline. Then, output $a_1, a_2, \cdots, a_k$, separated by spaces, followed by a newline.
  • 首先,输出 Second,并在末尾输出换行。
  • 然后,重复以下交互过程,直到游戏结束。
  • 首先,接收评测系统作为先手玩家的操作。接收两个整数 $i$ 和 $j$,其含义如下。
    • $i = -1$:此时 $j = -1$。这表示你在本题中被判定为错误。立即终止程序。
      • $i = 0$:此时 $j = 0$。这表示你在本题中被判定为正确。立即终止程序。
      • $i > 0$:这表示先手玩家从第 $i$ 堆取出了 $j$ 个石子。
    • 接下来,输出你作为后手玩家的操作。如果你从第 $a_1, a_2, \cdots, a_k$ 堆中各取出一个石子,首先输出 $k$ 并换行。然后输出 $a_1, a_2, \cdots, a_k$,各整数之间以空格分隔,并在末尾输出换行。
AI (CI翻译)

Note

说明

AI (CI翻译)
  • For each output, add a newline at the end and flush Standard Output. Otherwise, you may receive a TLE verdict.
  • If you win the game, you will be judged as correct.
  • If you lose the game, or if you make a malformed output, you will be judged as incorrect.
  • Once you receive from the judge that you have been judged correct or incorrect for this problem, terminate your program immediately. Otherwise, the verdict is indeterminate.
  • Note that extra newlines are considered as a malformed output.
  • 每次输出都要在末尾添加换行,并刷新标准输出。否则可能会被判定为 TLE。
  • 如果你赢得游戏,将被判定为正确。
  • 如果你输掉游戏,或输出格式错误,将被判定为错误。
  • 一旦从评测系统处收到你被判定为正确或错误的信息,请立即终止程序。否则,评测结果将无法确定。
  • 注意,额外的换行会被视为格式错误的输出。
AI (CI翻译)

Sample Interaction

样例交互

AI (CI翻译)
Sample Interaction $1$
样例交互 $1$
AI (CI翻译)

The following is an example of the interaction when $N = 3, K = 2$ and you play as the first player.

以下是当 $N = 3, K = 2$ 且你作为先手玩家进行游戏时的交互示例。AI (CI翻译)

Input Output Explanation
3 2 First, the integers $N, K$ are given.
First Output to the judge that you will play as the first player.
3 1 Remove one stone from pile $3$.
21 3 The judge removes one stone from each of piles $1, 3$.
1 1 Remove one stone from pile $1$.
12 The judge removes one stone from pile $2$.
2 1 Remove one stone from pile $2$.
0 The judge has lost because it became unable to make a move, which indicates that you won the game and have been judged as correct.
输入 输出 说明
3 2 首先,给出整数 $N, K$。
First 向评测系统输出你将作为先手玩家进行游戏。
3 1 从第 $3$ 堆取出一个石子。
21 3 评测系统从第 $1, 3$ 堆各取出一个石子。
1 1 从第 $1$ 堆取出一个石子。
12 评测系统从第 $2$ 堆取出一个石子。
2 1 从第 $2$ 堆取出一个石子。
0 评测系统因无法行动而输掉了游戏,这表示你赢得了游戏,并被判定为正确。
AI (CI翻译)
Sample Interaction $2$
样例交互 $2$
AI (CI翻译)

The following is an example of the interaction when $N = 2, K = 1$ and you play as the second player.

以下是当 $N = 2, K = 1$ 且你作为后手玩家进行游戏时的交互示例。AI (CI翻译)

Input Output Explanation
2 1 First, the integers $N, K$ are given.
Second Output to the judge that you will play as the second player.
1 1 The judge removes one stone from pile $1$.
12 Remove one stone from pile $2$.
0 0 The judge has lost because it became unable to make a move, which indicates that you won the game and have been judged as correct.
输入 输出 说明
2 1 首先,给出整数 $N, K$。
Second 向评测系统输出你将作为后手玩家进行游戏。
1 1 评测系统从第 $1$ 堆取出一个石子。
12 从第 $2$ 堆取出一个石子。
0 0 评测系统因无法行动而输掉了游戏,这表示你赢得了游戏,并被判定为正确。
AI (CI翻译)

These are merely examples of the interaction, and it is not guaranteed that the actual judge behaves in this way.

以上仅为交互示例,不能保证实际评测系统会以这种方式运行。AI (CI翻译)

题目信息
题号
arc231_d
时间限制
2 s
内存限制
1024 MB

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