結果

問題 No.2124 Guess the Permutation
ユーザー 👑 KazunKazun
提出日時 2022-11-18 21:29:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 421 bytes
コンパイル時間 1,128 ms
コンパイル使用メモリ 81,728 KB
実行使用メモリ 86,964 KB
平均クエリ数 374.60
最終ジャッジ日時 2023-10-20 06:16:24
合計ジャッジ時間 2,148 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
69,868 KB
testcase_01 AC 59 ms
69,868 KB
testcase_02 AC 59 ms
69,868 KB
testcase_03 AC 60 ms
69,868 KB
testcase_04 AC 64 ms
69,868 KB
testcase_05 AC 66 ms
69,868 KB
testcase_06 AC 103 ms
82,844 KB
testcase_07 AC 131 ms
86,964 KB
testcase_08 AC 130 ms
86,964 KB
testcase_09 AC 131 ms
86,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def quest(l,r):
    print("?",l,r,flush=True)
    return int(input())

def answer(P):
    print("!",*P[1:])
    exit()

def solve():
    N=int(input())

    P=[0]*(N+1)
    old=N*(N+1)//2
    for i in range(1,N-1):
        new=quest(i+1,N)
        P[i]=old-new
        old=new
    P[N]=N*(N+1)//2-quest(1,N-1)
    P[N-1]=N*(N+1)//2-sum(P)
    answer(P)

#==================================================
print(solve())
0