結果

問題 No.2124 Guess the Permutation
ユーザー ShirotsumeShirotsume
提出日時 2022-11-18 21:53:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 756 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 81,708 KB
実行使用メモリ 88,996 KB
平均クエリ数 374.60
最終ジャッジ日時 2023-10-20 06:43:31
合計ジャッジ時間 2,242 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,952 KB
testcase_01 AC 66 ms
71,952 KB
testcase_02 AC 67 ms
71,952 KB
testcase_03 AC 68 ms
71,952 KB
testcase_04 AC 71 ms
71,952 KB
testcase_05 AC 74 ms
71,952 KB
testcase_06 AC 110 ms
84,900 KB
testcase_07 AC 134 ms
88,996 KB
testcase_08 AC 133 ms
88,996 KB
testcase_09 AC 133 ms
88,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque, Counter
sys.setrecursionlimit(5 * 10 ** 5)
from pypyjit import set_param
set_param('max_unroll_recursion=-1')
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
mod = 998244353

def query(l, r):
    print('?', l + 1, r + 1, flush = True)
    return ii()

def answer(ans):
    print('!', *ans, flush = True)

n = ii()

ans = [0] * n

re = query(0, 1)

for i in range(2, n - 1):
    to = query(0, i)
    ans[i] = to - re
    re = to
ans[-1] = sum(range(1, n + 1)) - re

re = query(1, 2)

ans[1] = re - ans[2]

s = set(ans)
for i in range(1, n + 1):
    if i not in s:
        ans[0] = i
        break

answer(ans)
0