結果

問題 No.3598 Queen vs. King
コンテスト
ユーザー Kude
提出日時 2026-07-24 21:54:19
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
RE  
実行時間 -
コード長 1,272 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 238 ms
コンパイル使用メモリ 96,236 KB
実行使用メモリ 93,824 KB
平均クエリ数 205.75
最終ジャッジ日時 2026-07-24 21:56:52
合計ジャッジ時間 3,324 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 1 RE * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code


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
            give(d, h-w+d)
            x, y = get()
            if x == -1: continue
            give(y, h-2)
            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
0