Universal Cup Judging System

Universal Cup

Time Limit: 3 s Memory Limit: 2048 MB Total points: 100 Difficulty: [show] Interactive Hackable ✓
Statistics

這是一道互動題。請記得在每次輸出後清空輸出緩衝區。你可以使用以下方式:

  • fflush(stdout) 或 cout.flush(),適用於 C/C++;
  • System.out.flush(),適用於 Java 和 Kotlin;
  • sys.stdout.flush(),適用於 Python;
  • 其他語言請參閱其文件。

Little Cyan Fish 有一個長度為 $n+1$ 的秘密排列 $p_0,p_1,\ldots,p_n$,由 $0$ 到 $n$ 的整數組成。他希望你猜出這個秘密排列。為此,Little Cyan Fish 允許你進行不超過 $1024$ 次以下形式的詢問:

  • ? i j:取得滿足 $p_k=|p_i-p_j|$ 的索引 $k$($0\le k\le n$)。

當然,為了讓詢問合法,你必須保證 $i$ 和 $j$ 是 $[0,n]$ 內的兩個整數。例如,若 $p_0=2,p_1=0,p_2=1$,則詢問 ? 0 2 會得到索引 $2$,因為 $|p_0-p_2|=|2-1|=1=p_2$。

Little Cyan Fish 希望你想出一種策略來找出排列。當然,Little Cyan Fish 不希望你太輕易贏得遊戲。因此,他會根據情況調整排列 $p$ 來設下陷阱(詳見「互動」)。

輸入格式

有多組測試資料。輸入的第一行包含一個整數 $T$($1\le T\le100$),表示測試資料組數。

對於每組測試資料,輸入的第一行包含一個整數 $n$($1\le n\le1000$)。接著開始互動。

互動

若要詢問,請以以下格式輸出一行:

$$?\ i\ j$$

其中 $i$ 和 $j$ 是 $0$ 到 $n$ 之間的兩個整數。你必須確保詢問次數不超過 $1024$。作為回應,你會收到一個滿足 $p_k=|p_i-p_j|$ 的整數 $k$。

若要回報答案,請以以下格式輸出一行:

$$!\ p_0\ p_1\ \ldots\ p_n$$

其中 $p$ 是你要回報的排列。

輸出詢問或回報答案後,請不要忘記輸出換行字元並清空輸出串流。

本題的互動器會根據情況調整。這表示排列 $p$ 可能隨你的詢問而改變,只要它不與先前詢問的結果矛盾即可。

範例

互動範例 1

讀取:

1
3

輸出:

? 2 2

讀取:

1

輸出:

? 0 3

讀取:

3

輸出:

! 2 0 3 1

測試工具: 題目提供測試工具,幫助參賽者開發及測試解法。你可以從附件下載此工具。以 -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.