QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#172993 | #7178. Bishops | ucup-team298# | WA | 1ms | 3868kb | C++14 | 918b | 2023-09-09 21:33:12 | 2023-09-09 21:33:13 |
Judging History
answer
#include <bits/stdc++.h>
signed main ()
{
std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0);
int n, m, f = 0; std::cin >> n >> m;
if (n > m) std::swap(n, m), f = 1;
std::vector<std::pair<int, int>> ans;
if (n == 1) for (int i = 1; i <= m; i++) ans.emplace_back(1, i);
else
{
int o = 0;
for (int i = 1; i <= m; i += n - 1, o ^= 1)
if (!o) for (int j = 1; j <= n; j++) ans.emplace_back(j, i);
else for (int j = (n + 1) / 2; j <= n / 2 + 1; j++) ans.emplace_back(j, i);
if ((m - 1) % (n - 1))
{
int l = 1, r = n;
if (o) l = (n + 1) / 2, r = n / 2 + 1;
l += (m - 1) % (n - 1); r -= (m - 1) % (n - 1);
std::swap(l, r);
for (int j = l + 1; j <= r - 1; j++) ans.emplace_back(j, m);
}
}
std::cout << ans.size() << '\n';
for (auto &[u, v]: ans) if (f) std::swap(u, v);
for (auto [u, v]: ans) std::cout << u << " " << v << "\n";
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3868kb
input:
2 5
output:
10 1 1 2 1 1 2 2 2 1 3 2 3 1 4 2 4 1 5 2 5
result:
wrong answer Integer parameter [name=q] equals to 10, violates the range [0, 7]