結果

問題 No.2124 Guess the Permutation
ユーザー 👑 Kazun
提出日時 2022-11-18 21:29:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 421 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 86,360 KB
平均クエリ数 374.60
最終ジャッジ日時 2024-09-20 01:54:15
合計ジャッジ時間 1,845 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

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