問題一覧 > 通常問題

No.2124 Guess the Permutation

レベル : / AI推定難易度 : 850 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / リアクティブ問題 (詳しくはこちら)
タグ : (AC するまで非表示) / 解いたユーザー数 142
作問者 : 👑 qand / テスター : 👑 potato167 とりゐ
お気に入りにしたユーザー ProblemId : 8727 / 自分の提出
問題文最終更新日: 2022-11-17 09:23:12
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:
  • Choose a pair of integers $(l,r)$ satisfying $1\le l< r\le N$, and ask for the value of $\displaystyle \sum_{i=l}^r P_i$.
  • Guess the permutation that sounansya has.

    Constraints

  • All inputs are integers.
  • $3\le N\le 1000$
  • 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

  • Each time you print something, end it with a newline and flush standard output. Otherwise, the judge result may be TLE.
  • If you print invalid output during the interaction, the judge result is undefined.
  • Terminate your program immediately after answering with the permutation. Otherwise, the judge result is undefined.
  • The query that gives the answer is not counted toward the number of questions.
  • 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もしくは右上の雲マークをクリックしてアカウントを作成してください。