結果
問題 |
No.1384 Bishop and Rook
|
ユーザー |
|
提出日時 | 2021-01-08 14:24:56 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 435 ms / 2,000 ms |
コード長 | 889 bytes |
コンパイル時間 | 303 ms |
コンパイル使用メモリ | 82,688 KB |
実行使用メモリ | 83,780 KB |
最終ジャッジ日時 | 2024-07-03 23:22:05 |
合計ジャッジ時間 | 13,936 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 55 |
ソースコード
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)