結果

問題 No.2252 Find Zero
ユーザー Shirotsume
提出日時 2023-03-24 21:46:36
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 641 bytes
コンパイル時間 202 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 86,368 KB
平均クエリ数 81.44
最終ジャッジ日時 2024-09-18 16:57:54
合計ジャッジ時間 3,604 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13 WA * 2 RE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque, Counter
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(x, y):
    print('?', x, y, flush=True)
    return ii()

def answer(z):
    print('!', z, flush=True)
    exit()


n = ii()
s = set(range(n))
pos = {}
for i in range(n):
    if i not in s:
        continue
    s.discard(i)
    z = query(i, i)
    if z == i:
        answer(z)
    if z in pos and n % 2 == 0:
        answer(pos[z])
    
    s.discard(z)
    if len(s) == 1:
        answer(s.pop())
    pos[i] = z
0