题目收集
题目列表题单
返回列表

Sunbath

CodeforcesP0063· 1000ms· 256 MB· ZJU Summer 2026 Contest 6原题链接
交互图论

创建于 2026/07/18 · 更新于 2026/07/18

题目描述

This is an interactive problem.

There is a hidden tournament GGG on nnn vertices numbered from 111 to nnn.

A tournament is a directed graph such that for every pair of distinct vertices uuu and vvv, exactly one of the two directed edges (u,v)(u,v)(u,v) and (v,u)(v,u)(v,u) exists.

You may ask the interactor two non-empty disjoint sets of vertices AAA and BBB. The interactor will return the number of directed edges from AAA to BBB.

Your task is to find a set of vertices KKK such that ∣K∣≤⌈log⁡2n⌉+1|K| \le \lceil \log_2 n \rceil + 1∣K∣≤⌈log2​n⌉+1, and for every vertex v∉Kv \notin Kv∈/K, there exists a vertex u∈Ku \in Ku∈K such that (u,v)(u,v)(u,v) is an edge of GGG.

You have to find such a set KKK using no more than 2n+1502n+1502n+150 queries.

输入格式

First, read an integer TTT (1≤T≤1001 \le T \le 1001≤T≤100), denoting the number of test cases.

For each test case, first read an integer nnn (1≤n≤20001 \le n \le 20001≤n≤2000), denoting the number of vertices in the hidden tournament.

It is guaranteed that the sum of nnn over all test cases does not exceed 200020002000.

The interactor may be adaptive. However, for each test case, all answers are guaranteed to be consistent with at least one tournament on the current nnn vertices.

输出格式

To ask a query with two non-empty disjoint sets A={a1,a2,…,ap}A=\{a_1,a_2,\ldots,a_p\}A={a1​,a2​,…,ap​} and B={b1,b2,…,bq}B=\{b_1,b_2,\ldots,b_q\}B={b1​,b2​,…,bq​}, output:

? p a1 a2 … ap q b1 b2 … bq? \space p \space a_1 \space a_2 \space \ldots \space a_p \space q \space b_1 \space b_2 \space \ldots \space b_q? p a1​ a2​ … ap​ q b1​ b2​ … bq​

Here 1≤p,q≤n1 \le p,q \le n1≤p,q≤n, all vertices in AAA and BBB must be distinct, and A∩B=∅A \cap B = \varnothingA∩B=∅.

Then you should read an integer sss, denoting the number of ordered pairs (a,b)(a,b)(a,b) such that a∈Aa \in Aa∈A, b∈Bb \in Bb∈B, and (a,b)(a,b)(a,b) is an edge of GGG.

For each test case, the number of queries must not exceed 2n+1502n+1502n+150.

When you have found a valid set K={k1,k2,…,km}K=\{k_1,k_2,\ldots,k_m\}K={k1​,k2​,…,km​} for the current test case, output:

! m k1 k2 … km! \space m \space k_1 \space k_2 \space \ldots \space k_m! m k1​ k2​ … km​

Here 1≤m≤⌈log⁡2n⌉+11 \le m \le \lceil \log_2 n \rceil + 11≤m≤⌈log2​n⌉+1.

After outputting the answer, you should continue to the next test case.

样例输入 #1

1
4

4

样例输出 #1

? 2 1 2 2 3 4

! 2 1 2