#P9721. [EC Final 2022] Inversion

    ID: 9042 Type: RemoteJudge 1000ms 1024MiB Tried: 0 Accepted: 0 Difficulty: 5 Uploaded By: Tags>2022交互题Special JudgeO2优化ICPC

[EC Final 2022] Inversion

题目描述

This is an interactive problem.\textbf{This is an interactive problem.}

There is a hidden permutation p1,p2,,pnp_1, p_2, \dots, p_n of {1,2,,n}\{1, 2, \dots, n\}. You want to find it by asking the parity of the number of inversions of pl,,prp_l,\ldots, p_r.

You can query in the format ? l r{?~l~r}, and the interactor will respond you $\left( \sum_{l\leq i < j\leq r} [p_i > p_j]\right) \bmod 2$. [pi>pj][p_i>p_j] is 11 when pi>pjp_i>p_j and 00 when pipjp_i\le p_j.

输入格式

Firstly, you should read the integer nn (1n20001\le n\le 2000).

After that, you can make no more than 4×1044 \times 10^4 queries. To make a query, output ``? l r{?~l~r}'' (1lrn1 \leq l \leq r \leq n) on a separate line, then you should read the response from standard input.

To give your answer, print ``! p1 p2  pn{!~p_1~p_2~\dots~p_n}'' on a separate line. The output of the answer is \textbf{not} counted towards the limit of 4×1044 \times 10^4 queries.

After that, your program should terminate.

After printing a query, do not forget to output end of line and flush the output. To do this, use fflush(stdout)\texttt{fflush(stdout)} or cout.flush()\texttt{cout.flush()} in C++, System.out.flush()\texttt{System.out.flush()} in Java, flush(output)\texttt{flush(output)} in Pascal, or stdout.flush()\texttt{stdout.flush()} in Python.

It is guaranteed that the permutation is fixed in advance.

3

0

0

1


? 1 2

? 1 3

? 2 3

! 2 3 1