QOJ.ac
QOJ
ID | Submission ID | Problem | Hacker | Owner | Result | Submit time | Judge time |
---|---|---|---|---|---|---|---|
#369 | #164795 | #7178. Bishops | ucup-team1208 | ucup-team004 | Failed. | 2023-09-10 13:52:34 | 2023-09-10 13:52:36 |
Details
Extra Test:
Invalid Input
input:
8 4 12
output:
result:
FAIL Expected EOF (stdin, line 2)
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#164795 | #7178. Bishops | ucup-team004# | AC ✓ | 39ms | 12260kb | C++20 | 1.4kb | 2023-09-05 13:42:57 | 2023-09-05 13:42:57 |
answer
#include <bits/stdc++.h>
using i64 = long long;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, m;
std::cin >> n >> m;
std::vector<std::pair<int, int>> ans;
for (int t = 0; t < 2; t++) {
std::vector<std::vector<std::pair<int, int>>> a(n + m - 1);
for (int i = -m + 1; i < n; i++) {
if ((i + t) % 2) {
continue;
}
int l = std::max(-i, i);
int r = std::min(2 * n - 2 - i, 2 * m - 2 + i);
a[l].push_back({r, i});
}
std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>, std::greater<>> q;
for (int j = 0; j < n + m - 1; j++) {
for (auto [r, i] : a[j]) {
q.push({r, i});
}
if ((j + t) % 2) {
continue;
}
while (!q.empty()) {
auto [r, i] = q.top();
q.pop();
if (r < j) {
continue;
}
int x = (i + j) / 2 + 1;
int y = (j - i) / 2 + 1;
ans.push_back({x, y});
break;
}
}
}
std::cout << ans.size() << "\n";
for (auto [x, y] : ans) {
std::cout << x << " " << y << "\n";
}
return 0;
}