結果

問題 No.3018 目隠し宝探し
ユーザー mattu34
提出日時 2025-02-01 18:19:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 271 ms / 2,000 ms
コード長 2,983 bytes
コンパイル時間 565 ms
コンパイル使用メモリ 82,360 KB
実行使用メモリ 107,356 KB
平均クエリ数 2.59
最終ジャッジ日時 2025-02-01 18:19:52
合計ジャッジ時間 8,144 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

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}", flush=True)


H, W = mi()
if H == W == 1:
    print(f"! 1 1")
    exit()
candi = set()
y, x = 1, 1
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.add((i, j))
if len(candi) == 1:
    y, x = list(candi)[0]
    print(f"! {y} {x}", flush=True)
    exit()
y, x = 1, W
format(y, x)
res = ii()
cc = set()
for i, j in candi:
    if (y - i) ** 2 + (x - j) ** 2 == res:
        cc.add((i, j))
y, x = list(cc)[0]
print(f"! {y} {x}", flush=True)
0