CF1918E.ace5 and Task Order

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

This is an interactive problem!

In the new round, there were nn tasks with difficulties from 11 to nn . The coordinator, who decided to have the first round with tasks in unsorted order of difficulty, rearranged the tasks, resulting in a permutation of difficulties from 11 to nn . After that, the coordinator challenged ace5 to guess the permutation in the following way.

Initially, the coordinator chooses a number xx from 11 to nn .

ace5 can make queries of the form: ? i?\ i . The answer will be:

  • >> , if ai>xa_i > x , after which xx increases by 11 .
  • << , if ai<xa_i < x , after which xx decreases by 11 .
  • == , if ai=xa_i = x , after which xx remains unchanged.

The task for ace5 is to guess the permutation in no more than 40n40n queries. Since ace5 is too busy writing the announcement, he has entrusted this task to you.

输入格式

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

输出格式

The interaction between your program and the jury's program begins with reading a positive integer nn ( 1n20001 \leq n \leq 2000 ) — the length of the hidden permutation.

To make a query, output a line in the format "? i", where 1in1 \leq i \leq n .

As an answer, you will receive:

  • ">", if aia_i > xx , after which xx will increase by 11 .
  • "<", if aia_i < xx , after which xx will decrease by 11 .
  • "=", if aia_i = xx , after which xx will remain unchanged.

You can make no more than 40n40n queries. To output the answer, you need to print "! a_1 a_2 ... a_n", where 1ain1 \leq a_i \leq n , and all of them are distinct. Outputting the answer does not count as a query.

If your program makes more than 40n40n queries for one test case, or makes an invalid query, then the response to the query will be -1. After receiving such a response, your program should immediately terminate to receive the verdict Wrong Answer. Otherwise, it may receive any other verdict.

After outputting a query, do not forget to print a newline and flush the output buffer. Otherwise, you will receive the verdict Presentation Error. To flush the buffer, 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.

It is guaranteed that the sum of nn over all test cases does not exceed 20002000 .

The interactor in this problem is not adaptive.

Hacks:

To make a hack, use the following format:

The first line contains a single integer tt — the number of test cases.

The description of each test case should consist of two lines. The first line contains the numbers nn and xx ( 1xn20001 \leq x \leq n \leq 2000 ) — the length of the hidden permutation and the initial value of the number xx . The second line contains nn distinct numbers a1,a2,,ana_1, a_2, \ldots, a_n ( 1ain1 \leq a_i \leq n ) — the permutation that the jury should choose in this test case.

Sum of nn over all test cases should not exceed 20002000 .

输入输出样例

  • 输入#1

    2
    5
    
    >
    
    =
    
    <
    
    =
    
    <
    
    <
    
    2
    
    >

    输出#1

    ? 4
    
    ? 2
    
    ? 1
    
    ? 5
    
    ? 1
    
    ? 3
    
    ! 2 4 1 5 3
    
    ? 1
    
    ! 2 1

说明/提示

In the first test, the hidden permutation is aa = [ 2,4,1,5,32,4,1,5,3 ], and the initial value of xx is 33 .

In the second test, the hidden permutation is aa = [ 2,12,1 ], and the initial value of xx is 11 .

首页