結果

問題 No.1384 Bishop and Rook
ユーザー convexineqconvexineq
提出日時 2021-02-07 21:59:45
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 471 ms / 2,000 ms
コード長 1,061 bytes
コンパイル時間 1,812 ms
コンパイル使用メモリ 86,960 KB
実行使用メモリ 84,056 KB
最終ジャッジ日時 2023-09-17 21:35:01
合計ジャッジ時間 16,101 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,504 KB
testcase_01 AC 350 ms
81,868 KB
testcase_02 AC 237 ms
80,560 KB
testcase_03 AC 189 ms
80,112 KB
testcase_04 AC 203 ms
79,540 KB
testcase_05 AC 285 ms
81,408 KB
testcase_06 AC 316 ms
82,248 KB
testcase_07 AC 351 ms
82,548 KB
testcase_08 AC 321 ms
81,420 KB
testcase_09 AC 117 ms
77,720 KB
testcase_10 AC 268 ms
81,448 KB
testcase_11 AC 105 ms
77,472 KB
testcase_12 AC 133 ms
78,088 KB
testcase_13 AC 106 ms
77,356 KB
testcase_14 AC 401 ms
83,032 KB
testcase_15 AC 106 ms
77,272 KB
testcase_16 AC 456 ms
84,056 KB
testcase_17 AC 104 ms
77,156 KB
testcase_18 AC 131 ms
78,248 KB
testcase_19 AC 412 ms
83,788 KB
testcase_20 AC 104 ms
77,244 KB
testcase_21 AC 136 ms
78,048 KB
testcase_22 AC 135 ms
78,020 KB
testcase_23 AC 135 ms
78,028 KB
testcase_24 AC 138 ms
78,328 KB
testcase_25 AC 135 ms
78,500 KB
testcase_26 AC 142 ms
78,288 KB
testcase_27 AC 136 ms
78,416 KB
testcase_28 AC 136 ms
78,120 KB
testcase_29 AC 137 ms
78,280 KB
testcase_30 AC 135 ms
77,828 KB
testcase_31 AC 142 ms
78,268 KB
testcase_32 AC 133 ms
78,136 KB
testcase_33 AC 134 ms
77,824 KB
testcase_34 AC 138 ms
78,700 KB
testcase_35 AC 136 ms
78,320 KB
testcase_36 AC 132 ms
77,876 KB
testcase_37 AC 130 ms
78,276 KB
testcase_38 AC 133 ms
78,912 KB
testcase_39 AC 122 ms
78,288 KB
testcase_40 AC 137 ms
78,396 KB
testcase_41 AC 165 ms
78,216 KB
testcase_42 AC 161 ms
78,244 KB
testcase_43 AC 177 ms
78,584 KB
testcase_44 AC 178 ms
78,852 KB
testcase_45 AC 179 ms
79,700 KB
testcase_46 AC 165 ms
78,468 KB
testcase_47 AC 165 ms
78,572 KB
testcase_48 AC 168 ms
78,480 KB
testcase_49 AC 152 ms
78,380 KB
testcase_50 AC 151 ms
78,084 KB
testcase_51 AC 88 ms
76,408 KB
testcase_52 AC 471 ms
83,960 KB
testcase_53 AC 323 ms
82,352 KB
testcase_54 AC 96 ms
76,636 KB
testcase_55 AC 85 ms
76,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def f1(x,y):
    print(x+1,y-1)
    print(x,y-1)
    print(x+1,y)
    x += 1
    for i in range(m//2-1):
        y += 1
        print(x,y)
        x -= 1
        y += 1
        print(x,y)
        y -= 1
        print(x,y)
        x += 1
        y += 1
        print(x,y)
    return x,y

def f2(x,y):
    for i in range(m//2-1):
        x += 1
        y -= 1
        print(x,y)
        y += 1
        print(x,y)
        x -= 1
        y -= 1
        print(x,y)
        y -= 1
        print(x,y)
    print(x+1,y-1)
    print(x,y-1)
    print(x+1,y)
    x += 1
    return x,y


def solve(n,m):
    if n==m==1:
        print(0)
        print(1,1)
        return
    if n%2==1 or m%2==1:
        print(-1)
        return
    print(n*m-1)
    print(1,2)
    x,y = 1,2
    i = n//2
    while True:
        x,y = f1(x,y)
        i -= 1
        if i==0: break
        print(x+1,y)
        x,y = f2(x+1,y)
        i -= 1
        if i==0: break
        print(x+1,y)
        x += 1
    
T = int(input())
for _ in range(T):
    n,m = map(int,input().split())
    solve(n,m)
0