QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#170805 | #7178. Bishops | ucup-team1264# | WA | 13ms | 6768kb | C++20 | 1.0kb | 2023-09-09 15:59:56 | 2023-09-09 16:01:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
void solve() {
int n, m;
cin >> n >> m;
vector<int> vis_add(n + m + 1);
vector<int> vis_sub(n + m + 1); // i + m + 1 - j
vector<pair<int, int>> ans;
auto add = [&](int i, int j, int parity) {
if ((i + j) % 2 != parity) return;
if (vis_add[i + j] || vis_sub[i + m + 1 - j]) { return; }
vis_add[i + j] = 1, vis_sub[i + m + 1 - j] = 1;
ans.emplace_back(i, j);
};
for (int i = 1; i <= m; i++)
add(1, i, 0), add(n, i, 0);
for (int i = 1; i <= n; i++)
add(i, 1, 0), add(i, m, 0);
for (int i = m; i >= 1; i--)
add(n, i, 1), add(1, i, 1);
for (int i = n; i >= 1; i--)
add(i, m, 1), add(i, 1, 1);
cout << ans.size() << "\n";
for (auto [x, y] : ans)
cout << x << " " << y << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3444kb
input:
2 5
output:
6 1 1 1 3 1 5 2 5 2 3 2 1
result:
ok n: 2, m: 5, bishops: 6
Test #2:
score: 0
Accepted
time: 1ms
memory: 3512kb
input:
5 5
output:
8 1 1 5 1 1 3 5 3 5 4 1 4 5 2 1 2
result:
ok n: 5, m: 5, bishops: 8
Test #3:
score: 0
Accepted
time: 12ms
memory: 6664kb
input:
100000 100000
output:
199998 1 1 100000 2 1 3 100000 4 1 5 100000 6 1 7 100000 8 1 9 100000 10 1 11 100000 12 1 13 100000 14 1 15 100000 16 1 17 100000 18 1 19 100000 20 1 21 100000 22 1 23 100000 24 1 25 100000 26 1 27 100000 28 1 29 100000 30 1 31 100000 32 1 33 100000 34 1 35 100000 36 1 37 100000 38 1 39 100000 40 1 ...
result:
ok n: 100000, m: 100000, bishops: 199998
Test #4:
score: 0
Accepted
time: 13ms
memory: 6768kb
input:
100000 99999
output:
199998 1 1 100000 2 1 3 100000 4 1 5 100000 6 1 7 100000 8 1 9 100000 10 1 11 100000 12 1 13 100000 14 1 15 100000 16 1 17 100000 18 1 19 100000 20 1 21 100000 22 1 23 100000 24 1 25 100000 26 1 27 100000 28 1 29 100000 30 1 31 100000 32 1 33 100000 34 1 35 100000 36 1 37 100000 38 1 39 100000 40 1 ...
result:
ok n: 100000, m: 99999, bishops: 199998
Test #5:
score: -100
Wrong Answer
time: 12ms
memory: 5328kb
input:
100000 50000
output:
100000 1 1 100000 2 1 3 100000 4 1 5 100000 6 1 7 100000 8 1 9 100000 10 1 11 100000 12 1 13 100000 14 1 15 100000 16 1 17 100000 18 1 19 100000 20 1 21 100000 22 1 23 100000 24 1 25 100000 26 1 27 100000 28 1 29 100000 30 1 31 100000 32 1 33 100000 34 1 35 100000 36 1 37 100000 38 1 39 100000 40 1 ...
result:
wrong answer Participant's answer is not optimal (100000 < 149998)