結果

問題 No.2124 Guess the Permutation
ユーザー ninja-kidninja-kid
提出日時 2022-11-28 16:38:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 406 bytes
コンパイル時間 219 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 84,056 KB
平均クエリ数 374.60
最終ジャッジ日時 2024-04-15 15:59:56
合計ジャッジ時間 2,158 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
69,088 KB
testcase_01 AC 64 ms
69,080 KB
testcase_02 AC 67 ms
68,728 KB
testcase_03 AC 67 ms
68,864 KB
testcase_04 AC 71 ms
68,952 KB
testcase_05 AC 74 ms
69,464 KB
testcase_06 AC 114 ms
77,784 KB
testcase_07 AC 138 ms
83,544 KB
testcase_08 AC 134 ms
83,928 KB
testcase_09 AC 146 ms
84,056 KB
権限があれば一括ダウンロードができます

ソースコード

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