QOJ.ac

QOJ

حد الوقت: 6.0 s حد الذاكرة: 256 MB مجموع النقاط: 100 تفاعلية

#10072. 围桌而坐

الإحصائيات

有 $n$ 个人,编号从 $1$ 到 $n$。房间里有一张圆桌,恰好有 $n$ 个座位,每个人都有一个尚未公开的专属座位。

为了确定每个人的专属座位,你可以在餐厅组织最多 $60$ 次 $n$ 位客人的聚会。在每次聚会前,你可以决定客人到达的顺序。每次聚会后,你将收到一份名单,名单上的人是在秘密座位安排中,比其圆桌两侧邻居更早到达的客人。

请利用聚会结果收集到的信息,找出每个座位对应的客人。

交互

在交互开始前,评测程序会从测试数据中读取一个 $n$ 位客人的排列,并用它来回答查询。

交互开始时,首先读取一个整数 $n$ ($1 \le n \le 10^5$)。

之后你可以进行最多 $60$ 次查询。

进行查询时,输出一行格式为 ? p1 p2 ... pn 的内容(不含引号),其中 $p_1, p_2, \dots, p_n$ 是一个长度为 $n$ 的排列,代表客人到达聚会的顺序。每次查询后,读取一个整数 $k$,随后在同一行读取 $k$ 个不同的整数 $a_1, a_2, \dots, a_k$ ($1 \le a_i \le n$),这些是比其邻居更早到达的客人。

报告答案时,输出一行格式为 ! p1 p2 ... pn 的内容(不含引号),其中 $p_1, p_2, \dots, p_n$ 是一个长度为 $n$ 的排列,代表客人在圆桌上的座位顺序。你可以输出任何使得每位客人拥有与标准答案相同邻居的顺序。

如果查询格式不符合上述要求,你将收到 $-1$ 作为响应。在进行了 $60$ 次查询后,任何后续查询的响应都将是 $-1$。一旦收到此类响应,请终止程序以获得“Wrong Answer”判决。

在打印每一行后,请务必输出换行符并刷新输出缓冲区。否则,你将收到“Idleness limit exceeded”判决。刷新缓冲区的方法如下:

  • C++: fflush(stdout)cout.flush()
  • Java: System.out.flush()
  • Pascal: flush(output)
  • Python: stdout.flush()

样例

输入 1

6
2 1 2
2 5 6
2 3 5
2 3 2

输出 1

? 1 2 3 4 5 6
? 6 5 4 3 2 1
? 3 4 5 1 6 2
? 3 1 2 4 5 6
! 3 4 6 2 5 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.