結果

問題 No.2124 Guess the Permutation
ユーザー ThetaTheta
提出日時 2023-10-13 19:25:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 583 bytes
コンパイル時間 232 ms
コンパイル使用メモリ 10,876 KB
実行使用メモリ 24,288 KB
平均クエリ数 374.60
最終ジャッジ日時 2023-10-13 19:25:31
合計ジャッジ時間 2,141 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
23,424 KB
testcase_01 AC 37 ms
24,240 KB
testcase_02 AC 37 ms
23,756 KB
testcase_03 AC 39 ms
23,580 KB
testcase_04 AC 39 ms
23,688 KB
testcase_05 AC 42 ms
23,384 KB
testcase_06 AC 64 ms
24,288 KB
testcase_07 AC 80 ms
23,848 KB
testcase_08 AC 77 ms
23,932 KB
testcase_09 AC 79 ms
24,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N = int(input())
    P = []
    result = []
    for idx in range(2, N):
        print(f"? {idx} {N}", flush=True)
        response = int(input())
        result.append(response)
        if idx == 2:
            P.append(N * (N + 1) // 2 - response)
        elif idx >= 3:
            P.append(result[-2] - result[-1])

    print(f"? {1} {N-1}", flush=True)
    response = int(input())
    last = N * (N + 1) // 2 - response
    P.append(result[-1] - last)
    P.append(last)
    print("! " + " ".join(map(str, P)), flush=True)


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