QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100 Interactive

#1834. 歐拉圖?

Statistics

本題為互動題。

我們隱藏了一張有 $n$ 個頂點的無向圖 $G$。保證它連通,且沒有重邊或自環。

你最多可以進行 60 次以下形式的詢問:

  • 考慮 $G$ 的頂點集合的一個子集 $S$。$S$ 所導出的子圖有多少條邊?換句話說,$G$ 中有多少條邊的兩個端點都在 $S$ 中?

你的目標是判斷此圖是否存在歐拉迴路。歐拉迴路是一條恰好經過圖中每條邊一次,且起點和終點相同的路徑。

注意,圖 $G$ 在互動開始前就已固定。換句話說,互動程式不會自適應地改變圖。

輸入格式

第一行包含一個整數 $n$($3 \le n \le 10^4$),表示 $G$ 的頂點數。保證 $G$ 的邊數不超過 $10^5$,連通,且沒有重邊或自環。

互動

互動開始時,先讀取包含整數 $n$ 的一行。

要查詢 $G$ 中由 $k$ 個頂點 $x_1,x_2,\ldots,x_k$ 所導出的子圖的邊數,請輸出格式為 ? k x1 x2 ... xk 的一行($0 \le k \le n$,$1 \le x_i \le n$,所有 $x_i$ 互不相同)。

作為回應,評測程式會輸出一行,其中包含一個整數 $m$,表示這些邊的數量。

若詢問不合法,或詢問次數超過 60,評測程式將輸出 $-1$ 並結束互動。你會得到「答案錯誤」的評測結果。請務必立即終止程式,以免得到其他評測結果。

當你判定圖中是否有歐拉迴路後,請輸出一行:若存在,輸出 ! YES;否則輸出 ! NO。

每輸出一行後,別忘了輸出換行字元並清空輸出緩衝區。否則,你會得到「超過閒置時間限制」的評測結果。

範例

輸入格式 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.