結果
問題 |
No.2124 Guess the Permutation
|
ユーザー |
![]() |
提出日時 | 2022-11-18 23:41:18 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 929 bytes |
コンパイル時間 | 294 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 94,936 KB |
平均クエリ数 | 374.80 |
最終ジャッジ日時 | 2024-09-20 04:08:02 |
合計ジャッジ時間 | 2,396 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 WA * 1 |
ソースコード
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])}")