結果

問題 No.2124 Guess the Permutation
ユーザー ninja-kid
提出日時 2022-11-28 16:38:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 406 bytes
コンパイル時間 212 ms
コンパイル使用メモリ 81,780 KB
実行使用メモリ 83,800 KB
平均クエリ数 374.60
最終ジャッジ日時 2024-10-05 15:32:42
合計ジャッジ時間 1,796 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
base = (N + 1) * N // 2
ans = []

def check(l, r):
    print(f"? {l} {r}", flush=True)
    ret = int(input())
    return ret
    
first2 = check(2, N)
first = base - first2
for r in range(N - 1, 1, -1):
    res = check(1, r)
    val = base - res
    ans.append(str(val))
    base = res
ans.append(str(base - first))
ans.append(str(first))
result = ' '.join(ans[::-1])
print(f"! {result}")
0