結果
| 問題 | No.1384 Bishop and Rook |
| コンテスト | |
| ユーザー |
👑 SPD_9X2
|
| 提出日時 | 2021-02-07 22:44:25 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 679 ms / 2,000 ms |
| コード長 | 1,628 bytes |
| コンパイル時間 | 214 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 203,004 KB |
| 最終ジャッジ日時 | 2024-07-04 16:40:03 |
| 合計ジャッジ時間 | 14,884 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 55 |
ソースコード
"""
奇数だと無理?
"""
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)
SPD_9X2