QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#216852#7178. Bishopscardinal_city#WA 14ms9096kbPython31.5kb2023-10-16 02:43:362023-10-16 02:43:36

Judging History

你现在查看的是最新测评结果

  • [2023-10-16 02:43:36]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:9096kb
  • [2023-10-16 02:43:36]
  • 提交

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)