No.2124 Guess the Permutation
問題文最終更新日: 2022-11-17 09:23:12
English (AI translation)
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
yukicoder contest 368
(順位表)
の他の問題:
Problem Statement
This is an interactive problem.
sounansya has a permutation $P=(P_1,\ldots,P_N)$ of length $N$, obtained by rearranging the positive integers between $1$ and $N$, inclusive.You may ask the following question up to $N-1$ times:
Constraints
Input and Output
This is an interactive problem (a problem in which your program and the judge program interact through input and output).First, read the length $N$ of the permutation from standard input.
$N$
Then, repeat questions until you can determine the permutation.
Print each question to standard output in the following format.
$?$ $l$ $r$The response to this is given from standard input in the following format.
$S$Here, $S$ is the answer to the question.
Once you have determined the permutation, print it to standard output in the following format.
$!$ $P_1$ $\ldots$ $P_N$
Notes
Sample
The following is an example of an interaction that starts with $N=3$ and $P=(3,1,2)$.
| Input | Output | Explanation |
|---|---|---|
3 |
First, $N$ is given as input. | |
? 2 3 |
Ask for the value of $P_2+P_3$. | |
3 |
Since $P_2+P_3=3$, $3$ is returned. | |
? 1 2 |
Ask for the value of $P_1+P_2$. | |
4 |
Since $P_1+P_2=4$, $4$ is returned. | |
! 3 1 2 |
We now know that the answer is $P=(3,1,2)$, so print it. |
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
とりゐ