結果
| 問題 | No.3598 Queen vs. King |
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2026-07-24 21:51:24 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,324 bytes |
| 記録 | |
| コンパイル時間 | 248 ms |
| コンパイル使用メモリ | 95,980 KB |
| 実行使用メモリ | 93,824 KB |
| 平均クエリ数 | 4.00 |
| 最終ジャッジ日時 | 2026-07-24 21:53:14 |
| 合計ジャッジ時間 | 3,176 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | RE * 10 |
ソースコード
from itertools import product
def can_reach(src, dst):
src_x, src_y = src
dst_x, dst_y = dst
for cx, cy in product((-1, 0, 1), repeat=2):
if cx == cy == 0:
continue
if cx * src_x + cy * src_y == cx * dst_x + cy * dst_y:
return True
return False
def receive():
x, y = [int(s) for s in input().split()]
if (x, y) in ((0, 0), (-1, -1)):
is_end = True
else:
is_end = False
return is_end, (x, y)
def put(x, y):
print(x, y)
def solve():
H, W = [int(s) for s in input().split()]
_, (x1, y1) = receive()
put(x1, 1)
res, (x2, y2) = receive()
if res:
return
if x1 == x2:
curr_x, curr_y = x1, y2 - 1
if not (1 <= curr_y <= W):
curr_y = y2 + 1
else:
curr_x, curr_y = x1, y2
put(curr_x, curr_y)
res, (x3, y3) = receive()
if res:
return
for di, dj in product((-1, 1), repeat=2):
gi, gj = x3 + di, y3 + dj
if not (1 <= gi <= H and 1 <= gj <= W):
continue
if not can_reach((curr_x, curr_y), (gi, gj)):
continue
put(gi, gj)
break
res, _ = receive()
if res:
return
if __name__ == "__main__":
T = int(input())
for _ in range(T):
solve()