結果

問題 No.1384 Bishop and Rook
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-02-07 22:44:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 734 ms / 2,000 ms
コード長 1,628 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 87,284 KB
実行使用メモリ 194,588 KB
最終ジャッジ日時 2023-09-17 23:12:40
合計ジャッジ時間 20,055 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
71,492 KB
testcase_01 AC 499 ms
156,728 KB
testcase_02 AC 309 ms
128,380 KB
testcase_03 AC 217 ms
90,940 KB
testcase_04 AC 252 ms
99,352 KB
testcase_05 AC 385 ms
133,088 KB
testcase_06 AC 455 ms
154,084 KB
testcase_07 AC 517 ms
148,264 KB
testcase_08 AC 444 ms
145,100 KB
testcase_09 AC 148 ms
79,668 KB
testcase_10 AC 349 ms
133,828 KB
testcase_11 AC 143 ms
78,776 KB
testcase_12 AC 158 ms
79,348 KB
testcase_13 AC 144 ms
79,700 KB
testcase_14 AC 630 ms
192,340 KB
testcase_15 AC 143 ms
79,328 KB
testcase_16 AC 714 ms
190,100 KB
testcase_17 AC 124 ms
77,720 KB
testcase_18 AC 155 ms
79,308 KB
testcase_19 AC 607 ms
191,900 KB
testcase_20 AC 126 ms
77,832 KB
testcase_21 AC 141 ms
78,580 KB
testcase_22 AC 141 ms
78,372 KB
testcase_23 AC 140 ms
78,220 KB
testcase_24 AC 142 ms
78,776 KB
testcase_25 AC 156 ms
79,108 KB
testcase_26 AC 144 ms
78,436 KB
testcase_27 AC 140 ms
78,524 KB
testcase_28 AC 142 ms
78,844 KB
testcase_29 AC 158 ms
79,068 KB
testcase_30 AC 142 ms
78,744 KB
testcase_31 AC 148 ms
78,488 KB
testcase_32 AC 154 ms
78,940 KB
testcase_33 AC 139 ms
78,532 KB
testcase_34 AC 155 ms
79,180 KB
testcase_35 AC 140 ms
78,440 KB
testcase_36 AC 133 ms
78,460 KB
testcase_37 AC 149 ms
78,676 KB
testcase_38 AC 145 ms
78,636 KB
testcase_39 AC 133 ms
78,244 KB
testcase_40 AC 141 ms
78,536 KB
testcase_41 AC 217 ms
89,424 KB
testcase_42 AC 212 ms
88,528 KB
testcase_43 AC 224 ms
90,720 KB
testcase_44 AC 232 ms
92,532 KB
testcase_45 AC 232 ms
91,232 KB
testcase_46 AC 219 ms
90,448 KB
testcase_47 AC 226 ms
91,428 KB
testcase_48 AC 222 ms
90,612 KB
testcase_49 AC 193 ms
85,040 KB
testcase_50 AC 192 ms
84,620 KB
testcase_51 AC 122 ms
77,740 KB
testcase_52 AC 734 ms
194,588 KB
testcase_53 AC 436 ms
134,056 KB
testcase_54 AC 124 ms
77,808 KB
testcase_55 AC 115 ms
77,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


"""

奇数だと無理?


"""

import sys
import heapq
from collections import deque
from sys import stdin

TT = int(stdin.readline())

for i in range(TT):

    N,M = map(int,stdin.readline().split())

    if N == M == 1:
        print (0)
        print (1,1)
        continue

    elif N % 2 == 1 or M % 2 == 1:
        print (-1)
        continue

    print (N*M-1)

    ans = []

    x,y = 1,1

    for loop in range(M//2 + 2):

        for i in range(N//2-1):
            
            ans.append((x,y))
            
            x += 1 ; y += 1
            ans.append((x,y))
            
            x -= 1 ;
            ans.append((x,y))
            
            y -= 1 ; x += 1
            ans.append((x,y))

            x += 1


        ans.append((x,y))

        x += 1 ; y += 1
        ans.append((x,y))

        y -= 1
        ans.append((x,y))

        x -= 1 ; y += 1
        ans.append((x,y))

        y += 1


        ans.append((x,y))

        x += 1 ; y += 1
        ans.append((x,y))

        y -= 1
        ans.append((x,y))

        x -= 1 ; y += 1
        ans.append((x,y))

        x -= 1


        for i in range(N//2-1):
            
            ans.append((x,y))
            
            x -= 1 ; y -= 1
            ans.append((x,y))
            
            x += 1 ;
            ans.append((x,y))
            
            y += 1 ; x -= 1
            ans.append((x,y))

            x -= 1

        x += 1
        y += 1

    pl = [ [None]*N for i in range(M) ]
    for i in range(N*M):
        print (*ans[i])
        pl[ans[i][1]-1][ans[i][0]-1] = i

    for i in pl:
        pass
        #print (i)
0