QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 2048 MB Total points: 100 Interactive

#16802. 盲瓶

Statistics

你正在玩一个名为“盲瓶”(Blind Bottles)的游戏。游戏中有 $n$ 个瓶子,每个瓶子都有唯一的颜色。游戏主持人将它们排成一排,并对它们的顺序保密。你的目标是通过猜测来确定主持人的瓶子顺序。在每次猜测中,你需要提供一种瓶子的排列顺序。主持人会告诉你,在你的猜测中,有多少个瓶子处于正确的位置。当你做出的猜测将所有瓶子都放在正确的位置时,你就赢得了游戏。

你想赢得游戏,但你不想花一整天的时间来猜测。因此,你决定在最多 $10^4$ 次猜测内赢得游戏。

交互

这是一个交互式问题。

在输入开始时,你将收到一个整数 $n$ ($2 \le n \le 100$),表示瓶子的数量。瓶子的颜色用 $1$ 到 $n$ 之间的唯一整数标记。

读取该整数后,你的程序应开始进行猜测。在每次猜测中,输出一行包含 $n$ 个空格分隔的整数,这是 $1$ 到 $n$ 的一个排列。该排列代表你对顺序的一次猜测。

随后,你将收到一个整数 $k$ ($0 \le k \le n$),表示在你的猜测中处于正确位置的瓶子数量。如果 $k = n$,则你赢得了游戏,程序应当终止。如果 $k < n$,游戏将继续进行下一次猜测。如果你在 $10^4$ 次猜测后仍未赢得游戏,你的程序应当终止,并且你将获得 Wrong Answer(答案错误)的评测结果。

请不要忘记在每次打印猜测后刷新输出缓冲区(flush)。在游戏结束(无论是因为你获胜还是因为你达到了 $10^4$ 次猜测)后,你将不会收到任何进一步的输入。

评测程序是非对抗性的,这意味着瓶子的顺序在游戏开始时就已经确定,并且在游戏过程中不会改变。

样例

样例输入 1

5
2
3
5

样例输出 1

3 2 5 1 4
3 5 2 1 4
3 4 2 1 5

说明

在上述样例交互中:

  1. 评测机首先输入 $n = 5$。
  2. 程序输出猜测 3 2 5 1 4
  3. 评测机返回 $2$,表示有 $2$ 个瓶子位置正确。
  4. 程序输出猜测 3 5 2 1 4
  5. 评测机返回 $3$,表示有 $3$ 个瓶子位置正确。
  6. 程序输出猜测 3 4 2 1 5
  7. 评测机返回 $5$,表示所有瓶子位置正确,游戏结束。

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.