Universal Cup Judging System

Universal Cup

Límite de tiempo: 2.0 s Límite de memoria: 512 MB Puntuación total: 100 Interactivo
Estadísticas

这是一个交互式问题,你的程序将通过标准输入和标准输出与评测系统进行交互。

在 Duloc 王国,Farquaad 领主正在开发一个岗哨网络来监控他领土的每一个角落。他拥有一张岗哨和连接它们的道路的地图,形成了一个无向简单图 $G = (V, E)$,其中每个岗哨是一个顶点,每条道路是两个岗哨之间的一条边。然而,Farquaad 担心 Duloc 的某些部分可能是孤立的,导致无法从任何一个岗哨到达其他所有岗哨。

为了确保完全连通,他委托你验证他的网络是否连通。然而,有一个限制:你对图的信息访问权限有限。

你可以通过查询网络来调查其连通性。一次查询允许你选择一个岗哨子集 $S$,并接收不在 $S$ 中但与 $S$ 中至少一个岗哨有直接道路相连的岗哨数量。更准确地说,$\text{query}(S) = |N(S) \setminus S|$,其中 $S \subseteq V$ 且 $N(S) = \{x \mid \exists y \in S \text{ 使得 } (x, y) \in E\}$。

你的目标是高效地使用这些查询来确定网络是否连通。

你能帮助 Farquaad 领主通过验证 Duloc 网络中每个岗哨是否都能到达其他所有岗哨来确认他王国的安全吗?

输入格式

交互从读取一个整数开始 —— 顶点的数量。

然后你可以进行类型为 "? s"(不含引号)的查询,其中 $s$ 是一个长度为 $n$ 的二进制字符串,如果节点 $i \in S$,则字符 $s_i$ 为 1,否则为 0。查询后,读取一个整数 —— 你查询的答案。

打印查询后,不要忘记输出换行并刷新输出。交互器是非自适应的。在交互过程中图不会改变。

数据范围

$1 \le |V| \le 200$。 你最多可以使用 3500 次查询。

输出格式

当你确定 $G$ 是连通还是不连通时,以 "! x"(不含引号)的格式打印结果,其中如果 $G$ 是连通的,则 $x$ 为 1,否则为 0。

样例

输入格式 1

4
2
2
2

输出格式 1

? 1100
? 0010
? 1001
! 1

说明

在上述交互中,$|V| = 4, G = (V, E), V = \{1, 2, 3, 4\}, E = \{(1, 2), (2, 3), (3, 4), (2, 4)\}$。 - 4:给定 $|V|$。 - ? 1100:对子集 $\{1, 2\}$ 进行查询。 - 2:评测系统返回 2。 - ? 0010:对子集 $\{3\}$ 进行查询。 - 2:评测系统返回 2。 - ? 1001:对子集 $\{1, 4\}$ 进行查询。 - 2:评测系统返回 2。 - ! 1:算法检测到 $G$ 是连通的。

输入格式 2

2
0
0

输出格式 2

? 10
? 11
! 0

说明

这是另一个样例,$|V| = 2, G = (V, E), V = \{1, 2\}, E = \emptyset$。 - 2:给定 $|V|$。 - ? 10:对子集 $\{1\}$ 进行查询。 - 0:评测系统返回 0。 - ? 11:对子集 $\{1, 2\}$ 进行查询。 - 0:评测系统返回 0。 - ! 0:算法检测到 $G$ 是不连通的。

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.