結果
| 問題 | No.3598 Queen vs. King |
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2026-07-24 22:06:40 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 191 ms / 2,000 ms |
| + 2µs | |
| コード長 | 1,280 bytes |
| 記録 | |
| コンパイル時間 | 237 ms |
| コンパイル使用メモリ | 96,104 KB |
| 実行使用メモリ | 84,864 KB |
| 平均クエリ数 | 1787.50 |
| 最終ジャッジ日時 | 2026-07-24 22:06:50 |
| 合計ジャッジ時間 | 3,252 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 10 |
ソースコード
for _ in range(int(input())):
h, w = map(int, input().split())
flip = h > w
if flip:
h, w = w, h
def get():
x, y = map(int, input().split())
x -= 1
y -= 1
if flip:
y, x = x, y
return x, y
def give(x, y):
if flip:
y, x = x, y
print(x+1, y+1)
x, y = get()
if x == -1: continue
if x == h-2 and y == w-2:
give(0, w - h)
x, y = get()
if x == -1: continue
if x - y < h - w:
d = x
give(d, w-h+d)
x, y = get()
if x == -1: continue
give(x, w-2)
x, y = get()
assert x == -1
continue
else:
d = y - (w-h)
give(d, w-h+d)
x, y = get()
if x == -1: continue
give(h-2, y)
x, y = get()
assert x == -1
continue
elif x == h-2:
give(0, w-2)
x, y = get()
if x == -1: continue
give(x, w-2)
x, y = get()
assert x == -1
continue
else:
give(h-2, 0)
x, y = get()
if x == -1: continue
give(h-2, y)
x, y = get()
assert x == -1
continue
Kude