結果

問題 No.2124 Guess the Permutation
ユーザー hiragnhiragn
提出日時 2022-11-23 17:14:02
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 485 bytes
コンパイル時間 174 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 27,480 KB
平均クエリ数 374.60
最終ジャッジ日時 2024-09-24 20:57:34
合計ジャッジ時間 1,719 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    n = int(input())

    tot = n * (n + 1) // 2
    ans = []

    # a[1]~a[n-2]を決める
    for i in range(1, n - 1):
        print(f"? {i + 1} {n}")
        s = int(input())
        ai = tot - s
        ans.append(ai)
        tot -= ai

    # a[n-1]とa[n]を決める
    print(f"? {1} {n - 1}")
    s = int(input())
    an = n * (n + 1) // 2 - s
    ans.append(tot - an)
    ans.append(an)

    print("!", *ans)
    return


if __name__ == "__main__":
    main()
0