AT_arc231_d.Choose Your Role
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This is an interactive problem (where your program interacts with the judge system via Standard Input and Output).
There are N piles numbered from 1 to N. Each pile has N−1 stones.
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.
- 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.
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.
这是一个交互式问题(你的程序通过标准输入和输出与评测系统进行交互)。
有 N 堆石子,编号从 1 到 N。每堆石子恰好有 N−1 颗。
考虑由先手玩家和后手玩家使用这些石子进行的一场游戏。游戏中双方轮流行动,先手玩家先行。
- 先手玩家选择一堆至少含有一颗石子的石子堆,并从中移除 1 至 K 颗石子(含端点);
- 后手玩家选择 1 至 K 堆(含端点),且所选每堆均至少含有一颗石子,然后从每一堆中各移除一颗石子。
首位无法进行合法操作的玩家判负。你将与评测系统对弈本游戏。首先,你需要向评测系统声明自己担任先手玩家还是后手玩家,随后开始对弈。
说明/提示
Input and Output
This is an interactive problem (where your program interacts with the judge system via Standard Input and Output).
First, N and K are given in the following format; receive them from Standard Input.
N K
When playing as the first player
- First, output
Firstfollowed 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 a1,a2,⋯,ak are given, separated by spaces. This indicates that the second player removes one stone from each of piles a1,a2,⋯,ak.
When playing as the second player
-
First, output
Secondfollowed 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 a1,a2,⋯,ak, first output k followed by a newline. Then, output a1,a2,⋯,ak, separated by spaces, followed by a newline.### Notes
- First, receive the judge's move as the first player. Receive two integers i and j. They mean the following.
-
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.
Constraints
- 2≤N≤200
- 1≤K≤N
- All input values are integers.
输入与输出
本题为交互式问题(你的程序需通过标准输入/输出与评测系统进行交互)。
首先,按如下格式给出 N 和 K;请从标准输入读取它们。
N K
作为先手玩家时
- 首先,输出
First并换行。 - 然后,重复以下交互过程,直至游戏结束:
- 首先,输出你作为先手的一步操作。若你从第 i 堆中移除 j 颗石子,则按顺序输出 i 和 j(以空格分隔),并换行。
- 接着,读取评测系统作为后手的一步操作。首先读入一个整数 k,其含义如下:
- k=−1:表示你在此题中被判为错误。请立即终止程序。
- k=0:表示你在此题中被判为正确。请立即终止程序。
- k>0:随后会给出 k 个整数 a1,a2,⋯,ak(以空格分隔)。这表示后手玩家从第 a1,a2,⋯,ak 堆中各移除一颗石子。
作为后手玩家时
- 首先,输出
Second并换行。 - 然后,重复以下交互过程,直至游戏结束:
- 首先,读取评测系统作为先手的一步操作。读入两个整数 i 和 j,其含义如下:
- i=−1:此时 j=−1。表示你在此题中被判为错误。请立即终止程序。
- i=0:此时 j=0。表示你在此题中被判为正确。请立即终止程序。
- i>0:表示先手玩家从第 i 堆中移除了 j 颗石子。
- 接着,输出你作为后手的一步操作。若你从第 a1,a2,⋯,ak 堆中各移除一颗石子,则首先输出 k 并换行;然后在同一行或下一行(注意换行要求)输出 a1,a2,⋯,ak(以空格分隔),并换行。
- 首先,读取评测系统作为先手的一步操作。读入两个整数 i 和 j,其含义如下:
注意事项
- 每次输出后,务必在末尾添加换行符,并刷新标准输出缓冲区。否则可能收到 TLE 判定。
- 若你赢得游戏,则被判为正确。
- 若你输掉游戏,或输出格式非法,则被判为错误。
- 一旦从评测系统处接收到“本题判为正确”或“本题判为错误”的信号,请立即终止程序。否则判定结果不确定。
- 注意:多余的换行符被视为非法输出。
约束条件
- 2≤N≤200
- 1≤K≤N
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?