CodeTON Round 7 (Div. 1 + Div. 2, Rated, Prizes!)
G
Pepe Racing
Codeforces
3200
原题
← FH1 →
翻译中…

This is an interactive problem.

翻译中…

There are $n^2$ pepes labeled $1, 2, \ldots, n^2$ with pairwise distinct speeds. You would like to set up some races to find out the relative speed of these pepes.

翻译中…

In one race, you can choose exactly $n$ distinct pepes and make them race against each other. After each race, you will only know the fastest pepe of these $n$ pepes.

翻译中…

Can you order the $n^2-n+1$ fastest pepes in at most $2n^2 - 2n + 1$ races? Note that the slowest $n - 1$ pepes are indistinguishable from each other.

翻译中…

Note that the interactor is adaptive. That is, the relative speeds of the pepes are not fixed in the beginning and may depend on your queries. But it is guaranteed that at any moment there is at least one initial configuration of pepes such that all the answers to the queries are consistent.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

The only line of each test case contains a single integer $n$ ($2 \le n \le 20$) — the number of pepes in one race.

翻译中…

After reading the integer $n$ for each test case, you should begin the interaction.

翻译中…

It is guaranteed that the sum of $n^3$ over all test cases does not exceed $3 \cdot 10^5$.

翻译中…

Interaction

翻译中…

To set up a race, print a line with the following format:

翻译中…
  • $\mathtt{?}\,x_1\,x_2 \ldots x_n$ ($1 \le x_i \le n^2$, $x_i$ are pairwise distinct) — the labels of the pepes in the race.
翻译中…

After each race, you should read a line containing a single integer $p$ ($1\le p\le n^2$) — the label of the fastest pepe in the race.

翻译中…

When you know the $n^2-n+1$ fastest pepes, print one line in the following format:

翻译中…
  • $\mathtt{!}\,p_1\,p_2 \ldots p_{n^2 - n + 1}$ ($1 \le p_i \le n^2$, $p_i$ are pairwise distinct)
翻译中…

where $p$ is the sequence of these pepe's labels in descending order of speed.

翻译中…

After that, move on to the next test case, or terminate the program if no more test cases are remaining.

翻译中…

If your program performs more than $2n^2 - 2n + 1$ races for one test case or makes an invalid race, you may receive a Wrong Answer verdict.

翻译中…

After printing a query do not forget to output the end of the line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:

翻译中…
  • fflush(stdout) or cout.flush() in C++;
  • System.out.flush() in Java;
  • flush(output) in Pascal;
  • stdout.flush() in Python;
  • see the documentation for other languages.
翻译中…

Hack format

翻译中…

For hacks, use the following format.

翻译中…

The first line should contain $t$ — the number of test cases.

翻译中…

The first line of each test case should contain an integer $n$ followed by the string manual.

翻译中…

The second line of each test case should contain a permutation $a_1,a_2,\ldots,a_{n^2}$ of the integers from $1$ to $n^2$. $a_i \gt a_j$ if and only if pepe $i$ has a faster speed than pepe $j$.

翻译中…

As an example, the hack format for the example input is: $\mathtt{1}\\\mathtt{2}~\mathtt{manual}\\\mathtt{1}~\mathtt{2}~\mathtt{3}~\mathtt{4}$

翻译中…

样例

Input #1
1
2

2

4

4

3

2
Output #1
? 1 2

? 3 4

? 2 4

? 2 3

? 2 1

! 4 3 2
InputCopy OutputCopy
题目信息
题号
1896G
时间限制
5 s
内存限制
256 MB
标签
构造
模拟
交互题
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。