結果
問題 |
No.3018 目隠し宝探し
|
ユーザー |
![]() |
提出日時 | 2025-02-01 17:47:50 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,552 bytes |
コンパイル時間 | 346 ms |
コンパイル使用メモリ | 82,212 KB |
実行使用メモリ | 169,388 KB |
最終ジャッジ日時 | 2025-02-01 17:49:01 |
合計ジャッジ時間 | 70,889 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | TLE * 1 |
other | TLE * 21 |
ソースコード
YUKICODER = True from collections import * import sys import heapq from heapq import heapify, heappop, heappush import bisect from bisect import bisect_left, bisect_right import itertools from functools import lru_cache from types import GeneratorType from fractions import Fraction import math import copy import random # from atcoder.lazysegtree import LazySegTree if not YUKICODER: import numpy as np sys.setrecursionlimit(int(1e7)) # @lru_cache(maxsize=None) # CPython特化 # @bootstrap # PyPy特化(こっちのほうが速い) yield dfs(), yield Noneを忘れずに def bootstrap(f, stack=[]): # yield def wrappedfunc(*args, **kwargs): if stack: return f(*args, **kwargs) else: to = f(*args, **kwargs) while True: if type(to) is GeneratorType: stack.append(to) to = next(to) else: stack.pop() if not stack: break to = stack[-1].send(to) return to return wrappedfunc dxdy1 = ((0, 1), (0, -1), (1, 0), (-1, 0)) # 上下右左 dxdy2 = ( (0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (-1, -1), (1, -1), (-1, 1), ) # 8方向すべて dxdy3 = ((0, 1), (1, 0)) # 右 or 下 dxdy4 = ((1, 1), (1, -1), (-1, 1), (-1, -1)) # 斜め DIRECTION = {"L": (-1, 0), "R": (1, 0), "U": (0, 1), "D": (0, -1)} INF = float("inf") _INF = 1 << 60 MOD = 998244353 mod = 998244353 MOD2 = 10**9 + 7 mod2 = 10**9 + 7 # memo : len([a,b,...,z])==26 # memo : 2^20 >= 10^6 # 小数の計算を避ける : x/y -> (x*big)//y ex:big=10**9 # @:小さい文字, ~:大きい文字,None: 空の文字列 # ユークリッドの互除法:gcd(x,y)=gcd(x,y-x) # memo : d 桁以下の p 進表記を用いると p^d-1 以下のすべての # 非負整数を表現することができる # memo : (X,Y) -> (X+Y,X−Y) <=> 点を原点を中心に45度回転し、√2倍に拡大 # memo : (x,y)のx正から見た偏角をラジアンで(-πからπ]: math.atan2(y, x) # memo : a < bのとき ⌊a⌋ ≦ ⌊b⌋ input = lambda: sys.stdin.readline().rstrip() mi = lambda: map(int, input().split()) li = lambda: list(mi()) ii = lambda: int(input()) py = lambda: print("Yes") pn = lambda: print("No") pf = lambda: print("First") ps = lambda: print("Second") def format(y, x): print(f"? {y} {x}") H, W = mi() candi = set() y, x = H // 2, W // 2 format(y, x) res = ii() for j in range(1, W + 1): for i in range(1, H + 1): if (y - i) ** 2 + (x - j) ** 2 == res: candi.append((i, j)) if len(candi) > 1: if y - 1 > 0: yy = y - 1 format(yy, x) res = ii() for i, j in list(candi): if (yy - i) ** 2 + (x - j) ** 2 != res: candi.discard((i, j)) elif y + 1 <= H: yy = y + 1 format(yy, x) res = ii() for i, j in list(candi): if (yy - i) ** 2 + (x - j) ** 2 != res: candi.discard((i, j)) if len(candi) > 1: if x - 1 > 0: xx = x - 1 format(y, xx) res = ii() for i, j in list(candi): if (y - i) ** 2 + (xx - j) ** 2 != res: candi.discard((i, j)) elif x + 1 <= W: xx = x + 1 format(y, xx) res = ii() for i, j in list(candi): if (y - i) ** 2 + (xx - j) ** 2 != res: candi.discard((i, j)) y, x = list(candi)[0] print(f"! {y} {x}")