結果

問題 No.1384 Bishop and Rook
ユーザー mkawa2mkawa2
提出日時 2022-07-31 18:34:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 934 ms / 2,000 ms
コード長 1,218 bytes
コンパイル時間 380 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 8,684 KB
最終ジャッジ日時 2023-09-28 05:40:12
合計ジャッジ時間 18,414 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
8,228 KB
testcase_01 AC 530 ms
8,588 KB
testcase_02 AC 254 ms
8,620 KB
testcase_03 AC 106 ms
8,656 KB
testcase_04 AC 148 ms
8,644 KB
testcase_05 AC 379 ms
8,440 KB
testcase_06 AC 493 ms
8,464 KB
testcase_07 AC 582 ms
8,476 KB
testcase_08 AC 459 ms
8,464 KB
testcase_09 AC 24 ms
8,500 KB
testcase_10 AC 306 ms
8,612 KB
testcase_11 AC 20 ms
8,656 KB
testcase_12 AC 27 ms
8,500 KB
testcase_13 AC 22 ms
8,244 KB
testcase_14 AC 768 ms
8,464 KB
testcase_15 AC 24 ms
8,588 KB
testcase_16 AC 928 ms
8,648 KB
testcase_17 AC 21 ms
8,464 KB
testcase_18 AC 28 ms
8,596 KB
testcase_19 AC 738 ms
8,660 KB
testcase_20 AC 21 ms
8,516 KB
testcase_21 AC 38 ms
8,604 KB
testcase_22 AC 37 ms
8,552 KB
testcase_23 AC 33 ms
8,656 KB
testcase_24 AC 36 ms
8,620 KB
testcase_25 AC 36 ms
8,672 KB
testcase_26 AC 34 ms
8,552 KB
testcase_27 AC 34 ms
8,484 KB
testcase_28 AC 33 ms
8,512 KB
testcase_29 AC 35 ms
8,512 KB
testcase_30 AC 33 ms
8,608 KB
testcase_31 AC 29 ms
8,560 KB
testcase_32 AC 32 ms
8,672 KB
testcase_33 AC 30 ms
8,648 KB
testcase_34 AC 30 ms
8,544 KB
testcase_35 AC 30 ms
8,544 KB
testcase_36 AC 26 ms
8,624 KB
testcase_37 AC 26 ms
8,656 KB
testcase_38 AC 25 ms
8,560 KB
testcase_39 AC 25 ms
8,684 KB
testcase_40 AC 28 ms
8,512 KB
testcase_41 AC 101 ms
8,516 KB
testcase_42 AC 94 ms
8,648 KB
testcase_43 AC 115 ms
8,592 KB
testcase_44 AC 127 ms
8,620 KB
testcase_45 AC 126 ms
8,464 KB
testcase_46 AC 110 ms
8,452 KB
testcase_47 AC 121 ms
8,452 KB
testcase_48 AC 111 ms
8,452 KB
testcase_49 AC 70 ms
8,596 KB
testcase_50 AC 72 ms
8,604 KB
testcase_51 AC 16 ms
8,636 KB
testcase_52 AC 934 ms
8,476 KB
testcase_53 AC 394 ms
8,600 KB
testcase_54 AC 17 ms
8,496 KB
testcase_55 AC 15 ms
8,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
# md = 10**9+7
md = 998244353

def solve():
    h, w = LI()

    if h*w==1:
        print(0)
        print(1,1)
        return

    if h & 1 or w & 1:
        print(-1)
        return

    print(h*w-1)
    for i in range(0, h, 2):
        for j in range(w):
            if j%4 == 1: i += 1
            if j%4 == 3: i -= 1
            print(i+1, j+1)
        i ^= 1
        for j in range(w)[::-1]:
            if j%4 == 0: i += 1
            if j%4 == 2: i -= 1
            print(i+1, j+1)

for _ in range(II()):
    solve()
0