| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 5 초 | 2048 MB | 2 | 2 | 2 | 100.000% |
Ivan and Petr like to play with cacti --- special graphs where each edge belongs to at most one simple cycle, and the graph is connected. Multiple edges between pairs of vertices and loops are allowed.
They invent the following game:
After asking at most $8m$ questions, Ivan must determine, for every edge:
In this problem, each loop is considered a simple cycle of length $1$ and two edges between the same pair of vertices form a simple cycle of length $2$.
However, Ivan is still very young and only knows numbers up to $14$. So:
Also, to avoid having to list a lot of edges each time, Ivan always asks about an edge set obtained from the set used in one of the previous queries, or from the set of all edges, by removing exactly one edge.
Can you design a strategy that allows Ivan to complete this task?
Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 100$). The description of the test cases follows.
The first line of each test case contains $m$ ($1 \le m \le 10^4$) --- the number of edges in the cactus.
It is guaranteed that the sum of $m$ over all test cases does not exceed $10^4$.
To ask a query, output a line in the following format (without the quotes):
? $p$ $e$" ($0 \le p \le q$; $1 \le e \le m$), where $p$ is the number of a previous query or zero (queries are numbered from 1 in the order they are asked), $q$ is the number of queries made before the current one, $e$ is the label an edge. The query denotes a graph consisting of the edges used in the query number $p$ (or all edges if $p = 0$), with edge $e$ removed. The interactor checks whether this graph is connected when considering all original vertices and returns a single integer:
When you have found the answer, output a single line in the following format:
! $e_1$ $e_2$ $\dots$ $e_m$" ($-1 \le e_i \le 14$ for all $i$),where:
The interactor returns a single integer:
The interactor is not adaptive, meaning that the graph is fixed before you ask any queries.
1 7 0 1 1 1
? 0 1 ? 0 3 ? 2 4 ! -1 3 1 3 2 3 2
In the example interaction, the input and output contain empty lines to align interactor responses with queries. These empty lines do not appear in the actual input and output.
In this example, the graph has $5$ vertices and $7$ edges; edges $1$ through $7$, in this order, are $(1, 2)$, $(2, 3)$, $(3, 3)$, $(3, 4)$, $(4, 5)$, $(2, 4)$, $(4, 5)$.