QOJ.ac

QOJ

时间限制: 2 s 内存限制: 512 MB 总分: 100 交互

#1834. 欧拉图?

统计

这是一个交互式问题。

我们隐藏了一个包含 $n$ 个顶点的无向图 $G$。保证该图是连通的,且不包含重边或自环。

你可以进行最多 60 次以下形式的查询:

  • 考虑 $G$ 的所有顶点的一个子集 $S$。由 $S$ 导出的子图中包含多少条边?换句话说,$G$ 中有多少条边的两个端点都在 $S$ 中?

你的目标是确定该图中是否存在欧拉回路。欧拉回路是指图中经过每条边恰好一次,且起点和终点相同的路径。

注意:图 $G$ 在交互开始前就已经确定。换句话说,交互器不是自适应的。

你通过读取包含整数 $n$ ($3 \le n \le 10^4$) 的一行来开始交互。保证 $G$ 的边数不超过 $10^5$,且图是连通的,不包含重边或自环。

要查询 $G$ 中由 $k$ 个顶点 $x_1, x_2, \dots, x_k$ 导出的子图中的边数,请按以下格式打印一行: “? $k$ $x_1$ $x_2$ $\dots$ $x_k$” ($0 \le k \le n$, $1 \le x_i \le n$, 所有 $x_i$ 互不相同)。

作为响应,评测程序将打印一行,包含一个整数 $m$:即该子图中的边数。

如果你的查询无效,或者查询次数超过 60 次,评测程序将打印 $-1$ 并结束交互。你将收到“Wrong answer”的结果。请确保立即终止你的程序,以避免收到其他结果。

当你确定了图中是否存在欧拉回路后,打印一行:“! YES”(如果存在)或 “! NO”(如果不存在)。

在打印每一行后,不要忘记输出换行符并刷新输出。否则,你将收到“Idleness limit exceeded”的结果。

样例

输入格式 1

3
1
0

输出格式 1

? 2 1 2
? 2 1 3
! NO

说明

样例中的隐藏图是一个包含 3 个顶点,且边为 $(2, 1)$ 和 $(2, 3)$ 的图。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

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.