問題一覧 > 通常問題

No.1306 Exactly 2 Digits

レベル : / AI推定難易度 : 2100 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / リアクティブ問題 (詳しくはこちら)
タグ : (AC するまで非表示) / 解いたユーザー数 47
作問者 : butsurizuki / テスター : hirakich1000000007 harady_a_human
お気に入りにしたユーザー ProblemId : 5482 / 自分の提出
問題文最終更新日: 2020-12-03 01:50:56
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
Advent Calendar Contest 2020 (順位表) の他の問題:

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$
  1. 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$.
  2. 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$.
  3. If $p>q$, swap $p,q$.
  4. The pair $p$,$q$ is returned in this order, separated by a space.
This query can be used at most $1.5 \times (N^2-N)$ times (this value is always an integer). Using it more times than this results in an incorrect verdict. (The verdict is not guaranteed to be WA.)

! $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.
See also the samples for details.

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もしくは右上の雲マークをクリックしてアカウントを作成してください。