QOJ.ac

QOJ

Süre Sınırı: 1 s Bellek Sınırı: 2048 MB Toplam puan: 100 Zorluk: [göster] Etkileşimli Hack'lenebilir ✓

#22880. 猜图

İstatistikler

本题是一道交互题。

小青鱼有一个隐藏的包含 $n$ 个顶点的简单无向图,顶点编号为 $1$ 到 $n$。你知道 $n$ 的值,但你不知道任何一条边。小青鱼非常喜欢割(cut)这一概念。对于顶点集合 $S$,令 $\operatorname{cut}(S)$ 表示恰好有一个端点在 $S$ 中的边的数量。

problem_22880_c88365aab9e24b99bbd5b96995883b80.png

小青鱼允许你通过发起询问来比较割的大小。在一次询问中,你选择两个顶点集合 $S_1$ 和 $S_2$。小青鱼会告诉你 $\operatorname{cut}(S_1)$ 是小于、等于还是大于 $\operatorname{cut}(S_2)$。

你大概能猜到接下来的内容会和还原整张图有关,但这次的任务要简单一些。小青鱼会给你一个顶点 $u$,他希望你在至多 $n + 10$ 次询问内找出所有与 $u$ 相邻的顶点。

输入格式

输入的第一行包含两个整数 $n$ 和 $u$($1 \le n \le 1000$,$1 \le u \le n$),分别表示顶点的数量以及给定的顶点。随后,交互开始。

交互

要发起一次询问,请按以下格式输出一行:

$$?\ s_1\ s_2$$

其中 $s_1$ 和 $s_2$ 是长度为 $n$ 且仅由字符 0 和 1 组成的字符串。对于每个 $j \in \{1, 2\}$,顶点 $i$ 属于 $S_j$ 当且仅当 $s_j$ 的第 $i$ 个字符为 1。集合可以为空,可以重叠,也可以相等。

作为对该询问的回应,你将得到单个字符 <、= 或 >,分别表示 $\operatorname{cut}(S_1)$ 小于、等于或大于 $\operatorname{cut}(S_2)$。你必须保证发起的询问次数不超过 $n + 10$。

要汇报答案,请按以下格式输出一行:

$$!\ k\ v_1\ v_2\ \dots\ v_k$$

其中 $k$($0 \le k \le n - 1$)是与 $u$ 相邻的顶点数量,$v_1, v_2, \ldots, v_k$ 是这些顶点互不相同的编号(顺序任意)。如果 $k = 0$,则输出 ! 0。汇报答案不计入询问次数。在汇报答案后,你的程序必须立即终止。

在输出询问或汇报答案后,请不要忘记输出换行符并刷新输出缓冲区。如果你发起了不合法的询问或超过了询问次数限制,交互器将关闭输入流,此时你的程序必须立即终止。

在本题中,交互器是自适应的(adaptive)。这意味着只要不与之前的任何回应相矛盾,图就可能会根据你的询问发生改变。你的答案必须对所有与已收到的全部回应相一致的图都正确。

样例

输入格式 1

4 1

<

=

<

=

输出格式 1

? 0000 1000

? 0100 1100

? 0010 1010

? 0001 1001

! 2 2 4

说明

与样例交互相一致的一张图包含边 $(1, 2)$、$(1, 4)$ 和 $(2, 3)$。

problem_22880_2dcb0fb296e7aa6b2806ae2a9f6861fe.png

测试工具: 题目附件中提供了一个测试工具,以帮助选手开发和测试自己的程序。你可以从附件中下载该工具。使用 -h 选项运行该工具即可显示使用说明。该工具会检查交互过程和所汇报的答案,但不会强制限制运行时间或内存。

测试工具在整个交互过程中使用其输入文件中指定的固定图,而评测时的官方交互器是自适应的。通过测试工具的测试并不保证你的程序在面对官方交互器时一定正确。

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.