問題一覧 > 通常問題

No.3400 Nana's Plus Permutation Game (7 + 7) ÷ 7

レベル : / 実行時間制限 : 1ケース 2.777秒 / メモリ制限 : 512 MB / リアクティブ問題 (詳しくはこちら)
タグ : (AC するまで非表示) / 解いたユーザー数 6
作問者 : Sinonen / テスター : 👑 p-adic
お気に入りにしたユーザー ProblemId : 11385 / 自分の提出
問題文最終更新日: 2025-12-06 23:55:51
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. Show the original
Advent Calendar Contest 2025 (順位表) の他の問題:

Story

Let's play the permutation guessing game again. The strategy from last time has been found out.

By the way, how on earth are you supposed to handle dddd k d k d k dddd k d k d k dddd k dddd k ddkddkddkk and ddkddkddkk d k d k d kdkdkdk?

Problem Statement

There is a permutation $P = (P_1, P_2, \cdots,P_{N})$ of $(1, 2, \cdots, N)$ with $N$ elements. $N$ is a prime number. You are given $N$, but $P$ is not given and is kept hidden by the judge.

You can send the following query to the judge.

・Choose integers $i, j (i \neq j)$ between $1$ and $N$, inclusive. If there exists an integer $k$ such that $P_i + P_j = P_k$, you are given $k$; otherwise, you are given $-1$.

You can use this query up to $3N$ times. Find $P$.

Solve $T$ test cases.

Constraints

・$1 \leq T$

・$5 \leq N$

・$N$ is a prime number

・$P$ is a permutation of $(1, 2, \cdots, N)$

・$P$ is determined before the interaction and is fixed

・All inputs are integers

・The sum of $N$ over the test cases is at most $10001$

Input and Output

First, $T$ is given by the judge. After this, the following interaction is performed $T$ times.

$T$

First, at the beginning of each interaction, $N$ is given.
$N$

After that, you can send queries in the following format up to $3N$ times. They must satisfy $1 \leq i, j \leq N, i \neq j$.
$1$ $i$ $j$

The judge responds with the answer to the query. If there exists an integer $k$ such that $P_i + P_j = P_k$, $k$ is given; otherwise, $-1$ is given.
$k$

When outputting your answer, print it as follows. If this is the $T$-th time, terminate your program immediately.
$2$ $P_1$ $P_2$ $\cdots$ $P_N$

Notes

・After each output, print a trailing newline and flush the output.

・The judge's behavior for invalid output or actions may be undefined.

Sample

The following is one example.
Program's outputJudge's outputExplanation
1First, $T$ is given.
5First, $N$ is given. At this point, the judge is hiding $P =(1, 3, 4, 5, 2)$.
1 1 3The query $i = 1, j = 3$ is sent to the judge.
4Since $P_1 + P_3 = 5 = P_4$, $4$ is given.
1 2 3The query $i = 2, j = 3$ is sent to the judge.
-1Since $P_2 + P_3 = 7 > 5$, $-1$ is given.
2 1 4 2 3 5The permutation $(1, 4, 2, 3, 5)$ is output as the answer. This does not match $P$, so the answer is judged incorrect.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。