結果

問題 No.2124 Guess the Permutation
コンテスト
ユーザー terasa
提出日時 2022-11-18 23:42:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 944 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 262 ms
コンパイル使用メモリ 82,532 KB
実行使用メモリ 91,224 KB
平均クエリ数 374.60
最終ジャッジ日時 2024-09-20 04:08:12
合計ジャッジ時間 2,215 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 8 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from typing import List, Tuple, Optional
from collections import deque
import sys
import itertools
import heapq
import bisect
import math
from collections import deque, defaultdict
from functools import lru_cache, cmp_to_key

input = sys.stdin.readline

if __file__ != 'prog.py':
    sys.setrecursionlimit(10 ** 6)


def readints(): return map(int, input().split())
def readlist(): return list(readints())
def readstr(): return input()[:-1]


def query(l, r):
    print(f'? {l} {r}', flush=True)
    S = int(input())
    return S


N = int(input())
S = [query(i, i + 1) for i in range(1, N)]
for i in range(1, N + 1):
    used = {i}
    ans = [i]
    prev = i
    ok = True
    for s in S:
        nxt = s - prev
        if nxt < 1 or N < nxt or nxt in used:
            ok = False
            break
        ans.append(nxt)
        used.add(nxt)
        prev = nxt
    else:
        print(f"! {' '.join([str(n) for n in ans])}")
        exit()
0