Codeforces Round 1058 (Div. 1)
A
MAD Interactive Problem
Codeforces
1700
原题
←B →
翻译中…

This is an interactive problem.

翻译中…

There is a secret sequence $a_1, a_2, \ldots, a_{2n-1},a_{2n}$, which contains each integer from $1$ to $n$ exactly twice.

翻译中…

Your task is to guess the sequence by using queries of the following type:

翻译中…
  • "? $k\;j_1\;j_2\;\ldots\;j_k$" — select the integer $k$ ($1 \le k \le 2n$) and $k$ distinct indices $j_1, j_2, \ldots, j_k$ ($1 \le j_1 , j_2 , \ldots , j_k \le 2n$). In response to the query, the jury will return $\text{MAD}([a_{j_1}, a_{j_2}, \ldots, a_{j_k}])$.
翻译中…

We define the $\operatorname{MAD}$ (Maximum Appearing Duplicate) of an integer sequence as the largest integer that appears at least twice. Specifically, if there is no number that appears at least twice, the $\operatorname{MAD}$ value is $0$. Some examples are as follows:

翻译中…
  • $\operatorname{MAD}([1, 2, 1]) = 1$;
  • $\operatorname{MAD}([2, 2, 3, 3]) = 3$;
  • $\operatorname{MAD}([1, 2, 3, 4]) = 0$.
翻译中…

Please identify the secret sequence using at most $3n$ queries.

翻译中…

Input

翻译中…

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

翻译中…

The first line of each test case contains one integer $n$ ($2 \le n \le 300$).

翻译中…

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

翻译中…

After you read this line of input, the interaction begins with your first query.

翻译中…

Interaction

翻译中…

To make a query, output a line (without quotes) in the following format:

翻译中…
  • "? $k\;j_1\;j_2\;\ldots\;j_k$" ($1 \le k \le 2n$, $1 \le j_1 , j_2 , \ldots , j_k \le 2n$)
翻译中…

Here, the indices $j_1 , j_2 , \ldots , j_k$ which you selected must be pairwise distinct.

翻译中…

Then, after each query, read a single integer — the answer to your query.

翻译中…

You can make at most $3n$ queries of this type.

翻译中…

If your program has found the sequence $a$, print the line (without quotes) in the following format:

翻译中…
  • "! $a_1\;a_2\;\ldots\;a_{2n-1}\;a_{2n}$" ($1 \le a_i \le n$)
翻译中…

Note that this does not count towards the query limit.

翻译中…

After this, proceed to the next test case, or exit if this is the last test case.

翻译中…

The interactor in this task is not adaptive. In other words, the sequence $a$ does not change during the interaction.

翻译中…

If you make more than $3n$ queries during an interaction, your program must terminate immediately, and you will receive the Wrong Answer verdict. Otherwise, you can get an arbitrary verdict because your solution will continue to read from a closed stream.

翻译中…

After printing each line, do not forget to output the end of line and flush the output buffer. Otherwise, you will receive the Idleness Limit Exceeded verdict. To flush, use:

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

Hacks

翻译中…

To make a hack, please use the following format:

翻译中…

The first line should contain the number of test cases $t$ ($1 \leq t \leq 3000$).

翻译中…

The first line of each test case should contain an integer $n$ ($2 \leq n \leq 300$).

翻译中…

The following line should contain $2n$ integers $a_1,a_2,\ldots,a_{2n}$ ($1 \leq a_i \leq n$). Each number from $1$ through $n$ must appear exactly twice.

翻译中…

The sum of $n^2$ over all test cases should not exceed $10^5$.

翻译中…

For example, the hack format corresponding to the example interaction is as follows.

翻译中…

2
2
2 2 1 1
2
1 2 1 2

翻译中…

Note

翻译中…

In the first test case, the hidden sequence is $a=[2,2,1,1]$.

翻译中…

For the query "? 2 2 1", the jury returns $2$ because $\operatorname{MAD}([a_2, a_1]) = \operatorname{MAD}([2, 2]) = 2$.

翻译中…

For the query "? 2 1 3", the jury returns $0$ because $\operatorname{MAD}([a_1, a_3]) = \operatorname{MAD}([2, 1]) = 0$.

翻译中…

For the query "? 3 1 3 4", the jury returns $1$ because $\operatorname{MAD}([a_1, a_3, a_4]) = \operatorname{MAD}([2 ,1, 1]) = 1$.

翻译中…

Note that the example interaction is only for understanding statements and does not guarantee finding a unique sequence $a$.

翻译中…

样例

Input #1
2
2

2

0

1

2

0

1

1
Output #1
? 2 2 1

? 2 1 3

? 3 1 3 4

! 2 2 1 1

? 2 1 2

? 2 1 3

? 3 1 3 4

! 1 2 1 2
InputCopy OutputCopy
题目信息
题号
2159A
时间限制
2 s
内存限制
256 MB
标签
构造
模拟
交互题

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