結果
| 問題 | No.3598 Queen vs. King |
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2026-07-24 21:46:14 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,261 bytes |
| 記録 | |
| コンパイル時間 | 234 ms |
| コンパイル使用メモリ | 96,092 KB |
| 実行使用メモリ | 94,080 KB |
| 平均クエリ数 | 3.75 |
| 最終ジャッジ日時 | 2026-07-24 21:46:18 |
| 合計ジャッジ時間 | 3,251 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| 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
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()