Universal Cup Judging System

Universal Cup

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

呢題係互動題。記得每次輸出之後都要清空輸出緩衝區。你可以用以下方法:

  • C/C++ 用 fflush(stdout) 或 cout.flush();
  • Java 同 Kotlin 用 System.out.flush();
  • Python 用 sys.stdout.flush();
  • 其他語言請睇返相關文件。

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.