No.1306 Exactly 2 Digits
タグ : / 解いたユーザー数 47
作問者 :
butsurizuki
/ テスター :
harady_a_human
Note
This is the problem for Day 3 of Advent Calendar Contest 2020.
It is one of the rejected problems from Codeforces Round #654(Div.2).
Problem Statement
This is an interactive problem.
$A=\{A_1,A_2,...,A_{N^2-N}\}$ is a permutation containing each of $\{N,N+1,...,N^2-1\}$ exactly $1$ time. (These are the numbers with exactly $2$ digits in base $N$.)
Identify this permutation using the following query.
? $i$ $j$
- Let $p = \lfloor A_i/N \rfloor - \lfloor A_j/N \rfloor $. Intuitively, $p$ is (the $N$'s digit of $A_i$) $-$ (the $N$'s digit of $A_j$) in base $N$.
- Let $q = A_i\%N - A_j\%N$. Intuitively, $q$ is (the $1$'s digit of $A_i$) $-$ (the $1$'s digit of $A_j$) in base $N$.
- If $p>q$, swap $p,q$.
- The pair $p$,$q$ is returned in this order, separated by a space.
! $A_1$ $A_2$ ... $A_{N^2-N}$
This query outputs the sequence you have identified. After this output, the program must terminate immediately.Input and Output
First, an integer $N$ is given on $1$ line. $N$ is an integer satisfying $2 \le N \le 50$.
After that, you may perform some queries. Print each query on $1$ line, ending with a newline.
For each ? query, the response is given on $1$ line.
There is no response to the ! query. After printing this query, terminate the program immediately.
You must flush in your program after each output. For how to flush in some languages, you can refer to the examples here.
Notes
The judge of this problem may be adaptive.
An adaptive judge is a judge that satisfies the following.
- The judge initially assumes some solution and responds to the submitted program accordingly.
- The judge may change the solution it assumes at any time, as long as it is consistent with the responses given so far.
Sample
Sample 1
Input
2 -1 0
Output
? 2 1 ! 3 2
In this case, $A= \{ 3,2 \}$.
For ? 2 1, initially $p=0$ , $q=-1$.
However, since $p>q$, the final response is -1 0.
The final output $\{3,2\}$ is correct, and the verdict is AC.
Sample 2
Input
3 1 2
Output
? 4 1 ! 3 5 4 8 7 6
In this case, $A= \{ 3,5,4,8,7,6 \}$.
For ? 4 1, initially $p=1$ , $q=2$.
Since $p \le q$, the final response is 1 2.
The final output $\{3,5,4,8,7,6\}$ is correct, but other sequences such as $\{ 3,6,7,8,4,5 \}$ are also consistent with the judge's output.
Therefore, the sequence $A$ may be replaced at judging time, and you may receive an incorrect verdict.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。