Codeforces Round 922 (Div. 2)
E
ace5 and Task Order
Codeforces
2200
原题
← DF →
翻译中…

This is an interactive problem!

翻译中…

In the new round, there were $n$ tasks with difficulties from $1$ to $n$. 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 $1$ to $n$. After that, the coordinator challenged ace5 to guess the permutation in the following way.

翻译中…

Initially, the coordinator chooses a number $x$ from $1$ to $n$.

翻译中…

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

翻译中…
  • $ \gt $, if $a_i \gt x$, after which $x$ increases by $1$.
  • $ \lt $, if $a_i \lt x$, after which $x$ decreases by $1$.
  • $=$, if $a_i = x$, after which $x$ remains unchanged.
翻译中…

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

翻译中…

Input

翻译中…

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

翻译中…

Interaction

翻译中…

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

翻译中…

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

翻译中…

As an answer, you will receive:

翻译中…
  • ">", if $a_i$ > $x$, after which $x$ will increase by $1$.
  • "<", if $a_i$ < $x$, after which $x$ will decrease by $1$.
  • "=", if $a_i$ = $x$, after which $x$ will remain unchanged.
翻译中…

You can make no more than $40n$ queries. To output the answer, you need to print "! a_1 a_2 ... a_n", where $1 \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 $40n$ 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 $n$ over all test cases does not exceed $2000$.

翻译中…

The interactor in this problem is not adaptive.

翻译中…

Hacks:

翻译中…

To make a hack, use the following format:

翻译中…

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

翻译中…

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

翻译中…

Sum of $n$ over all test cases should not exceed $2000$.

翻译中…

Note

翻译中…

In the first test, the hidden permutation is $a$ = [$2,4,1,5,3$], and the initial value of $x$ is $3$.

翻译中…

In the second test, the hidden permutation is $a$ = [$2,1$], and the initial value of $x$ is $1$.

翻译中…

样例

Input #1
2
5

>

=

<

=

<

<

2

>
Output #1
? 4

? 2

? 1

? 5

? 1

? 3

! 2 4 1 5 3

? 1

! 2 1
InputCopy OutputCopy
题目信息
题号
1918E
时间限制
2 s
内存限制
256 MB
标签
构造
分治
模拟
交互题
概率论
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。