QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#216852 | #7178. Bishops | cardinal_city# | WA | 14ms | 9096kb | Python3 | 1.5kb | 2023-10-16 02:43:36 | 2023-10-16 02:43:36 |
Judging History
answer
[n, m] = map(int, input().split())
# if n % m == 0 or m % n == 0:
# print(n + m - 2)
# else:
# print(n + m - 1)
ans = []
a = min(n, m)
b = max(n, m)
if a == b:
ans = [(k, 1) for k in range(1, a + 1)]
ans += [(k, b) for k in range(2, a)]
print(len(ans))
for t in ans:
print(t[0], t[1])
else:
ans = [(k, 1) for k in range(1, a + 1)]
ans += [(k, b) for k in range(1, a + 1)]
if a % 2 == 1:
x = (a + 1) // 2
ans += [(x, k) for k in range(x + 1, b - x + 1)]
else:
x = a // 2 + 1
ans += [(x, k) for k in range(x + 1, b - x + 1)]
print(len(ans))
if a == m:
ans = [(t[1], t[0]) for t in ans]
for t in ans:
print(t[0], t[1])
# def get_pairs(a, b):
# print(a,b)
# if a > b:
# return [(t[1], t[0]) for t in get_pairs(b, a)]
# elif a == 1:
# return [(1, k) for k in range(1, b + 1)]
# elif a == 0:
# return []
# elif b % a == 0:
# num = b // a
# ans = [(k, 1 + a * x) for k in range(1, a + 1) for x in range(num)]
# ans += [(k, b) for k in range(2, a)]
# return ans
# else:
# num = b // a
# ans = [(k, 1 + a * x) for k in range(1, a + 1) for x in range(num)]
# ans += [(t[0], t[1] + a * num) for t in get_pairs(a, b % a)]
# return ans
# ans = get_pairs(n, m)
# print(len(ans))
# # for t in ans:
# # print(t[0], t[1])
详细
Test #1:
score: 0
Wrong Answer
time: 14ms
memory: 9096kb
input:
2 5
output:
5 1 1 2 1 1 5 2 5 2 3
result:
wrong answer Participant's answer is not optimal (5 < 6)