Codeforces Global Round 13
F
Magnets
Codeforces
2700
原题
← EG →
翻译中…

This is an interactive problem.

翻译中…

Kochiya Sanae is playing with magnets. Realizing that some of those magnets are demagnetized, she is curious to find them out.

翻译中…

There are $n$ magnets, which can be of the following $3$ types:

翻译中…
  • N
  • S
  • - — these magnets are demagnetized.
翻译中…

Note that you don't know the types of these magnets beforehand.

翻译中…

You have a machine which can measure the force between the magnets, and you can use it at most $n+\lfloor \log_2n\rfloor$ times.

翻译中…

You can put some magnets to the left part of the machine and some to the right part of the machine, and launch the machine. Obviously, you can put one magnet to at most one side (you don't have to put all magnets). You can put the same magnet in different queries.

翻译中…

Then the machine will tell the force these magnets produce. Formally, let $n_1,s_1$ be the number of N and S magnets correspondently on the left and $n_2,s_2$ — on the right. Then the force between them would be $n_1n_2+s_1s_2-n_1s_2-n_2s_1$. Please note that the force is a signed value.

翻译中…

However, when the absolute value of the force is strictly larger than $n$, the machine will crash into pieces.

翻译中…

You need to find all magnets of type - (all demagnetized ones), without breaking the machine.

翻译中…

Note that the interactor is not adaptive. The types of the magnets are fixed before the start of the interaction and do not change with queries.

翻译中…

It is guaranteed that there are at least $2$ magnets whose type is not -, and at least $1$ magnet of type -.

翻译中…

Input

翻译中…

The first line contains a single integer $t$ ($1 \leq t \leq 100$) — the number of test cases.

翻译中…

Interaction

翻译中…

For each test case you should start by reading an integer $n$ ($3 \leq n \leq 2000$) — the number of the magnets.

翻译中…

It is guaranteed that the total sum of all $n$ over all test cases doesn't exceed $2000$.

翻译中…

After that you can put some magnets into the machine and make a query from the statement.

翻译中…

You have to print each query in three lines:

翻译中…
  • In the first line print "? l r" (without quotes) where $l$ and $r$ ($1 \leq l,r \lt n$, $l+r \leq n$) respectively denote the number of the magnets you put to left and right.
  • In the second line print $l$ integers $a_1, \dots, a_l$ ($1 \leq a_i \leq n$, $a_i \neq a_j$ if $i \neq j$) — the indices of the magnets you put to left.
  • In the third line print $r$ integers $b_1, \dots, b_r$ ($1 \leq b_i \leq n$, $b_i \neq b_j$ if $i \neq j$) — the indices of the magnets you put to right.
  • The same magnet can't be put to both sides in the same query. Formally, you should guarantee that $a_i \neq b_j$ for any $i$ and $j$. However, you may leave some magnets unused.
翻译中…

After printing a query do not forget to output end of line and flush the output. 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 documentation for other languages.
翻译中…

After this, you should read an integer $F$ — the force these magnets produce.

翻译中…

Note that if your query is invalid(either the query limit exceeds, the machine crashes or the arguments are invalid), the interactor will terminate immediately. In this case terminate your program to receive verdict Wrong Answer instead of arbitrary verdicts.

翻译中…

If you are confident about your answer, use the following format to report it:

翻译中…
  • "! k A", where $k$ is the number of magnets you found, and $A$ is an array consisting of $k$ different integers from $1$ to $n$ denoting the indices of the magnets of type - that you found. You may print elements of $A$ in arbitrary order.
  • After that, if this is the last test case, you have to terminate your program; otherwise you should immediately continue to deal with the next test case.
翻译中…

Note that the interactor is not adaptive. The types of the magnets are fixed before the start of interaction and do not change with queries.

翻译中…

Hacks

翻译中…

To hack a solution, use the following format:

翻译中…

The first line contains a single integer $t$ ($1 \leq t \leq 100$) — the number of test cases in your hack.

翻译中…

Then follow the descriptions of the $t$ test cases, each printed in two lines:

翻译中…
  • The first line contains a single integer $n$ ($3 \leq n \leq 2000$) — the number of magnets.
  • The second line contains a string $S$ of length $n$ consisting of only N, S and -, denoting the magnets' types.
  • Each of your test case should guarantee that there are at least $2$ magnets whose type is not -, and at least $1$ magnet of type -. Meanwhile, the total sum of $n$ in all test cases should not exceed $2000$.
翻译中…

Note

翻译中…

The empty lines in the sample are just for you to better understand the interaction process. You're not required to print them.

翻译中…

In the sample, the types of the magnets are NN--.

翻译中…

At first, you put the third magnet on the left and the fourth one on the right. Both of them have type -, thus no force is produced.

翻译中…

Then you put the first magnet on the left and the second and third one on the right. The third magnet has type -, while the other two magnets are of type N, so the force produced is $1$.

翻译中…

In the following two queries, the force is $0$ since there is only a magnet with property - on the right.

翻译中…

Then we can determine that the magnets of type - are the third and the fourth one, so we should print ! 2 3 4 and exit.

翻译中…

样例

Input #1
1
4

0

1

0

0
Output #1
? 1 1
3
4

? 1 2
1
2 3

? 1 1
1
4

? 1 1
1
3

! 2 3 4
InputCopy OutputCopy
题目信息
题号
1491F
时间限制
1 s
内存限制
256 MB
标签
二分
构造
交互题

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