CF1896G.Pepe Racing

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

This is an interactive problem.

There are n2n^2 pepes labeled 1,2,,n21, 2, \ldots, n^2 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 nn distinct pepes and make them race against each other. After each race, you will only know the fastest pepe of these nn pepes.

Can you order the n2n+1n^2-n+1 fastest pepes in at most 2n22n+12n^2 - 2n + 1 races? Note that the slowest n1n - 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 tt ( 1t1041 \le t \le 10^4 ). The description of the test cases follows.

The only line of each test case contains a single integer nn ( 2n202 \le n \le 20 ) — the number of pepes in one race.

After reading the integer nn for each test case, you should begin the interaction.

It is guaranteed that the sum of n3n^3 over all test cases does not exceed 31053 \cdot 10^5 .

输出格式

To set up a race, print a line with the following format:

  • ?x1x2xn\mathtt{?}\,x_1\,x_2 \ldots x_n ( 1xin21 \le x_i \le n^2 , xix_i are pairwise distinct) — the labels of the pepes in the race.

After each race, you should read a line containing a single integer pp ( 1pn21\le p\le n^2 ) — the label of the fastest pepe in the race.

When you know the n2n+1n^2-n+1 fastest pepes, print one line in the following format:

  • !p1p2pn2n+1\mathtt{!}\,p_1\,p_2 \ldots p_{n^2 - n + 1} ( 1pin21 \le p_i \le n^2 , pip_i are pairwise distinct)

where pp 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 2n22n+12n^2 - 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 tt — the number of test cases.

The first line of each test case should contain an integer nn followed by the string manual.

The second line of each test case should contain a permutation a1,a2,,an2a_1,a_2,\ldots,a_{n^2} of the integers from 11 to n2n^2 . ai>aja_i > a_j if and only if pepe ii has a faster speed than pepe jj .

As an example, the hack format for the example input is: 12 manual1 2 3 4\mathtt{1}\\\mathtt{2}~\mathtt{manual}\\\mathtt{1}~\mathtt{2}~\mathtt{3}~\mathtt{4}

输入输出样例

  • 输入#1

    1
    2
    
    2
    
    4
    
    4
    
    3
    
    2

    输出#1

    ? 1 2
    
    ? 3 4
    
    ? 2 4
    
    ? 2 3
    
    ? 2 1
    
    ! 4 3 2
首页