QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 1024 MB Points totaux : 100

#5595. 猎杀Wumpus

Statistiques

Hunt the Wumpus 是一个你在 $10 \times 10$ 网格上与计算机对战的游戏。游戏开始时,四个 Wumpus 被随机放置在网格上(没有两个 Wumpus 占据同一个位置)。你需要找到并捕获所有四个 Wumpus。你通过输入两个十进制数字作为坐标来猜测一个方格。如果你猜中了某个 Wumpus 的位置,系统会告知你,该 Wumpus 将被捕获并从网格中移除。无论你是否击中 Wumpus,系统都会向你报告你的猜测与最近的 Wumpus 之间的曼哈顿距离。你可以利用这一点来定位并找到每个 Wumpus。当最后一个 Wumpus 被捕获时,游戏结束。

你需要编写该游戏的计算机端程序。用户的猜测和随机生成的 Wumpus 位置由一个两位数定义,其中高位数字为 $x$,低位数字为 $y$,对应点 $(x, y)$。

为了使游戏具有确定性,我们将使用我们自己的伪随机数生成器,并提供一个种子 $s$。每个随机数是通过首先执行 $s \leftarrow s + \lfloor s/13 \rfloor + 15$,然后返回 $s$ 的两个低位数字来生成的。此过程中生成的第一个四个不同的数字即为四个 Wumpus 的位置。对于种子 $132$,第一个位置由 $132 + 10 + 15$ 的两个低位数字给出,即 $57$,对应位置 $(5, 7)$。

输入格式

第一行包含一个整数 $s$ ($10^4 \le s \le 10^6$),即随机数生成器的种子。其余每一行包含一个两位数(可能带有前导零)。这些是玩家所做的猜测,每一个对应一个网格位置。

输入将始终格式正确,并描述一个完整的游戏。最后一次用户猜测将始终找到最后一个 Wumpus。任何输入中最多有 $250$ 次猜测。

输出格式

输出计算机对玩家每次猜测的响应。如果猜测击中了 Wumpus,你应该输出一行 “You hit a wumpus!”。无论玩家是否击中 Wumpus,如果仍有未被捕获的 Wumpus,请输出到最近的剩余 Wumpus 的曼哈顿距离。两点 $(x_1, y_1)$ 和 $(x_2, y_2)$ 之间的曼哈顿距离为 $|x_1 - x_2| + |y_1 - y_2|$,因此它始终是一个整数。

在游戏结束时,通过输出一行 “Your score is m moves.” 来报告定位所有 Wumpus 所需的总步数 $m$。

样例

样例输入 1

203811
00
01
02
03

样例输出 1

You hit a wumpus!
1
You hit a wumpus!
1
You hit a wumpus!
1
You hit a wumpus!
Your score is 4 moves.

样例输入 2

101628
00
40
60
68
78
95

样例输出 2

4
You hit a wumpus!
2
You hit a wumpus!
8
1
You hit a wumpus!
5
You hit a wumpus!
Your score is 6 moves.

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.