QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#173237 | #7178. Bishops | ucup-team1631# | AC ✓ | 0ms | 0kb | Python3 | 608b | 2023-09-09 22:35:58 | 2023-09-09 22:35:58 |
Judging History
answer
def calc(H,W):
if H>W:
ans=[]
for x,y in calc(W,H):
ans.append((y,x))
return ans
use1=set()
use2=set()
ans=[]
for x in range(1,H+1):
for y in [1,W]:
if x+y not in use1 and x-y not in use2:
ans.append((x,y))
use1.add(x+y)
use2.add(x-y)
for y in range(1,W+1):
for x in [(H+1)//2,(H+2)//2]:
if x+y not in use1 and x-y not in use2:
ans.append((x,y))
use1.add(x+y)
use2.add(x-y)
return ans
H,W=map(int,input().split())
ans=calc(H,W)
print(len(ans))
for x,y in ans:
print(x,y)
详细
Test #1:
score: 0
Dangerous Syscalls
input:
2 5