結果

問題 No.3018 目隠し宝探し
ユーザー kmmtkm
提出日時 2025-01-25 15:03:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 1,134 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 81,664 KB
実行使用メモリ 76,288 KB
平均クエリ数 2.59
最終ジャッジ日時 2025-01-25 23:39:40
合計ジャッジ時間 4,209 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys


def debug(*args):
    print(*args, file=sys.stderr)


h, w = map(int, input().split())
# cdds = [(i, j) for i in range(1, h+1) for j in range(1, h+1)]

# asks = [(1, h), (h, w), (1, 1)]
# while len(cdds) > 1 and asks:
#     new_cdds = []
#     ai, aj = asks.pop()
#     print('?', ai, aj)
#     d = int(input())
#     if d == -1:
#         exit()
#     for i, j in cdds:
#         if (i-ai) ** 2 + (j-aj) ** 2 == d:
#             new_cdds.append((i, j))

#     cdds, new_cdds = new_cdds, cdds
#     # debug('d', cdds)
# if not cdds:
#     exit()
# print('!', *cdds[0])
if h == 1 and w == 1:
    print('!', 1, 1)
    exit()

print('?', 1, 1)
d = int(input())
if d == -1:
    exit()

cdds = []
for i in range(1, h+1):
    for j in range(1, w+1):
        if (i-1)**2 + (j-1)**2 == d:
            cdds.append((i, j))
# debug(cdds)

if len(cdds) == 1:
    print('!', *cdds[0])
else:
    ai, aj = cdds[0]
    print('?', ai, aj)
    d = int(input())
    if d == -1:
        exit()

    for i, j in cdds:
        if (i-ai)**2 + (j-aj)**2 == d:
            print('!', i, j)
            exit()
    print(-1)
    input()
    exit()
0