CF1896G.Pepe Racing
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This is an interactive problem.
There are n2 pepes labeled 1,2,…,n2 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 n2−n+1 fastest pepes in at most 2n2−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.
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t ( 1≤t≤104 ). The description of the test cases follows.
The only line of each test case contains a single integer n ( 2≤n≤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 n3 over all test cases does not exceed 3⋅105 .
输出格式
To set up a race, print a line with the following format:
- ?x1x2…xn ( 1≤xi≤n2 , xi 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≤p≤n2 ) — the label of the fastest pepe in the race.
When you know the n2−n+1 fastest pepes, print one line in the following format:
- !p1p2…pn2−n+1 ( 1≤pi≤n2 , pi 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 2n2−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 a1,a2,…,an2 of the integers from 1 to n2 . ai>aj if and only if pepe i has a faster speed than pepe j .
As an example, the hack format for the example input is: 12 manual1 2 3 4
输入输出样例
输入#1
1 2 2 4 4 3 2
输出#1
? 1 2 ? 3 4 ? 2 4 ? 2 3 ? 2 1 ! 4 3 2