結果

問題 No.2124 Guess the Permutation
ユーザー hiragnhiragn
提出日時 2022-11-23 17:14:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 485 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 11,868 KB
実行使用メモリ 26,592 KB
平均クエリ数 374.60
最終ジャッジ日時 2023-10-25 02:01:32
合計ジャッジ時間 1,701 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
26,476 KB
testcase_01 AC 50 ms
26,476 KB
testcase_02 AC 50 ms
26,476 KB
testcase_03 AC 50 ms
26,476 KB
testcase_04 AC 52 ms
26,480 KB
testcase_05 AC 53 ms
26,480 KB
testcase_06 AC 72 ms
26,528 KB
testcase_07 AC 90 ms
26,592 KB
testcase_08 AC 90 ms
26,592 KB
testcase_09 AC 89 ms
26,592 KB
権限があれば一括ダウンロードができます

ソースコード

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