QOJ.ac

QOJ

时间限制: 1 s 内存限制: 1024 MB 总分: 100 交互 可 Hack ✓

#14263. Squirdle

统计

Squirtle(杰尼龟)设计了一个名为 Squirdle 的猜单词游戏。在游戏中,Squirtle 心中想好了一个由 $5$ 个字母组成的字符串(其中每个字母都是互不相同的英文小写字母 a-z)。Squirtle 给你 $10$ 次猜测的机会来猜出这个单词。在每次猜测后,他会告诉你猜测的每个字符是在正确的位置、错误的位置,还是根本不在字符串中。请在最多 $10$ 次猜测内猜出 Squirtle 的单词!

交互

这是一个交互式问题。你将通过标准输入和输出与 Squirtle 进行交互。

要猜测一个字符串 $s$,请按以下格式向标准输出打印一行:

  • ? s(其中 $s$ 是一个仅由英文小写字母组成的 $5$ 字符字符串)

Squirtle 将通过标准输入回复一行:一个由数字 012 组成的长度为 $5$ 的字符串。每个位置上的数字为你提供了关于猜测 $s$ 中对应位置字符 $c$ 的信息:

  • 0 — $c$ 不在字符串中。
  • 1 — $c$ 在字符串中,但处于不同的位置。
  • 2 — $c$ 在字符串中,且处于完全相同的位置。

当收到字符串 22222(这意味着你已经正确猜出了 Squirtle 的单词)或当你用完所有 $10$ 次猜测时,交互结束。你的程序在做出正确猜测后应当立即终止。

在每次猜测后,请确保输出一个换行符并刷新输出流。为此,请使用:

  • C 中的 fflush(stdout)
  • C++ 中的 cout.flush()
  • Java 中的 System.out.flush()
  • Python 中的 stdout.flush()

样例

样例输入 1

00000
20201
22222

样例输出 1

? frogs
? zebra
? zubat

说明

在样例交互中:

  1. 你的程序输出 ? frogs
  2. 评测机输入 00000,表示 f, r, o, g, s 都不在目标单词中。
  3. 你的程序输出 ? zebra
  4. 评测机输入 20201,表示 zb 在正确的位置,a 在单词中但位置不对,er 不在单词中。
  5. 你的程序输出 ? zubat
  6. 评测机输入 22222,表示你已成功猜出单词,程序随后终止。

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.