結果

問題 No.1384 Bishop and Rook
ユーザー MitarushiMitarushi
提出日時 2021-01-08 14:24:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 482 ms / 2,000 ms
コード長 889 bytes
コンパイル時間 998 ms
コンパイル使用メモリ 85,984 KB
実行使用メモリ 85,440 KB
最終ジャッジ日時 2023-09-17 01:03:29
合計ジャッジ時間 17,609 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,024 KB
testcase_01 AC 328 ms
82,764 KB
testcase_02 AC 238 ms
80,448 KB
testcase_03 AC 184 ms
79,508 KB
testcase_04 AC 196 ms
80,240 KB
testcase_05 AC 275 ms
81,520 KB
testcase_06 AC 339 ms
82,488 KB
testcase_07 AC 366 ms
82,864 KB
testcase_08 AC 317 ms
81,372 KB
testcase_09 AC 126 ms
78,276 KB
testcase_10 AC 263 ms
80,520 KB
testcase_11 AC 127 ms
78,448 KB
testcase_12 AC 131 ms
78,164 KB
testcase_13 AC 127 ms
78,348 KB
testcase_14 AC 468 ms
83,848 KB
testcase_15 AC 186 ms
78,276 KB
testcase_16 AC 482 ms
85,440 KB
testcase_17 AC 128 ms
77,936 KB
testcase_18 AC 133 ms
77,992 KB
testcase_19 AC 438 ms
85,232 KB
testcase_20 AC 137 ms
78,052 KB
testcase_21 AC 134 ms
78,036 KB
testcase_22 AC 138 ms
77,824 KB
testcase_23 AC 140 ms
77,712 KB
testcase_24 AC 135 ms
77,732 KB
testcase_25 AC 135 ms
77,800 KB
testcase_26 AC 135 ms
77,836 KB
testcase_27 AC 136 ms
77,936 KB
testcase_28 AC 134 ms
77,736 KB
testcase_29 AC 135 ms
77,820 KB
testcase_30 AC 135 ms
77,884 KB
testcase_31 AC 129 ms
77,736 KB
testcase_32 AC 132 ms
77,956 KB
testcase_33 AC 134 ms
77,828 KB
testcase_34 AC 144 ms
77,616 KB
testcase_35 AC 137 ms
77,616 KB
testcase_36 AC 139 ms
77,860 KB
testcase_37 AC 132 ms
77,972 KB
testcase_38 AC 133 ms
77,844 KB
testcase_39 AC 122 ms
78,700 KB
testcase_40 AC 137 ms
77,824 KB
testcase_41 AC 168 ms
78,232 KB
testcase_42 AC 160 ms
78,432 KB
testcase_43 AC 173 ms
78,688 KB
testcase_44 AC 179 ms
78,772 KB
testcase_45 AC 179 ms
79,136 KB
testcase_46 AC 170 ms
78,620 KB
testcase_47 AC 172 ms
78,760 KB
testcase_48 AC 163 ms
78,592 KB
testcase_49 AC 148 ms
77,928 KB
testcase_50 AC 149 ms
77,924 KB
testcase_51 AC 91 ms
76,372 KB
testcase_52 AC 473 ms
84,764 KB
testcase_53 AC 381 ms
82,868 KB
testcase_54 AC 96 ms
76,284 KB
testcase_55 AC 85 ms
76,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in range(int(input())):
    n, m = map(int, input().split())
    if n == 1 and m == 1:
        print("0\n1 1")
        continue
    if n % 2 == 1 or m % 2 == 1:
        print(-1)
        continue
    print(n*m - 1)
    for i in range(0, n, 2):
        t = range(0, m, 2)
        for j in (t if i % 4 == 0 else reversed(t)):
            if i % 4 == 0:
                if j == 0:
                    print(i+1, j+2)
                    print(i+2, j+1)
                else:
                    print(i+2, j+1)
                    print(i+1, j+2)
                print(i+1, j+1)
                print(i+2, j+2)
            else:
                print(i+1, j+2)
                print(i+2, j+1)
                if j == 0:
                    print(i+1, j+1)
                    print(i+2, j+2)
                else:
                    print(i+2, j+2)
                    print(i+1, j+1)
0