QOJ.ac

QOJ

시간 제한: 2.0 s 메모리 제한: 512 MB 총점: 100 인터랙티브

#16958. Interactive Knockout

통계

这是一个交互式问题。你需要在一系列独立的对局中击败随机移动的评测机(jury)。

游戏在一个使用轴向坐标(axial coordinates)的六边形棋盘上进行。该棋盘由一个六边形边界限定,其顶点位于单元格 $(n, 0)$、$(0, n)$、$(-n, n)$、$(-n, 0)$、$(0, -n)$ 和 $(n, -n)$。在除本题说明中的样例(该样例不在实际测试集中)之外的所有测试点中,均有 $n = 20$。

游戏有两名玩家——你和评测机。你的起点在单元格 $(-n/2, 0)$,评测机的起点在单元格 $(n/2, 0)$。双方轮流移动,你先手。

$n = 4$ 时的棋盘(蓝色单元格是你的起点,红色单元格是评测机的起点)。

在每个回合中,玩家可以移动到任意一个与其相邻(共边)的单元格,该单元格不能包含对手且未被摧毁。移动后,先前占用的单元格将被摧毁,在后续回合中不再对玩家开放。无法移动到任何相邻单元格的玩家输掉游戏。

评测机没有想出任何聪明的算法来玩这个游戏,因此他们决定在每个回合中等概率随机地移动到任意一个合法的相邻单元格。

你需要展现你的绝对统治力——赢得全部 $t$ 局独立的对局。

交互格式

第一行输入两个整数 $t$ 和 $n$——你需要赢得的独立对局数,以及棋盘大小($1 \le t \le 50$;除不在实际测试集中的样例之外,其余测试点均有 $n = 20$)。

在每个回合中,你需要输出一行表示你移动的方向——两个整数 $dx, dy$,其中 $(dx, dy) \in \{(1, 0), (0, 1), (-1, 1), (-1, 0), (0, -1), (1, -1)\}$。之后,读取一行以下格式的输入:

  • 字符串 move 和两个整数 $dx, dy$ —— 评测机移动的方向 $(dx, dy)$。保证该方向是在所有合法移动中等概率随机选择的;
  • 字符串 win —— 如果评测机没有任何合法的单元格可以移动。在这种情况下,你应该立即开始下一局游戏,或者如果已经完成了所有 $t$ 局游戏,则以退出码 0 结束程序。
  • 字符串 lose —— 如果你进行了一次不合法的移动。在这种情况下,你应该以退出码 0 结束程序,以获得相应的“Wrong answer”评测结果。

保证最多有 100 个测试点(每个测试点最多有 50 局游戏),你总共需要赢得最多 5000 局游戏。评测机在每个测试点中使用固定的随机种子。

样例

样例输入 1

2 4
move -1 1
move -1 1
move -1 1
move 0 1
move -1 0
win
move 0 -1
move -1 0
lose

样例输出 1

0 1
0 1
0 1
-1 0
-1 1
1 0
1 0
1 -1
1 0

说明

请注意,样例测试点中的交互最终会导致“Wrong answer”评测结果,因为在 2 局游戏中只赢了 1 局。这两局游戏的对局过程如下图所示。

先手玩家获胜(左图)以及因进行不合法移动而失败(右图)。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.