QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#174342 | #7178. Bishops | ucup-team1766# | WA | 2ms | 3768kb | C++23 | 1.1kb | 2023-09-10 06:37:23 | 2023-09-10 06:37:23 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m; cin >> n >> m;
bool flip = false;
if (n > m) swap(n, m), flip =true;
long long ans = 0;
vector<array<int,2>> print;
int i = 0, j = m-1;
while (j - i >= n) {
ans += 2*n;
for (int k = 0; k < n; k++) {
print.push_back({k, i});
print.push_back({k, j});
}
i += n;
j -= n;
}
if (i == j) {
ans += n;
for (int k = 0; k < n; k++) {
print.push_back({k, i});
}
} else if (i < j) {
ans += n;
for (int k = 0; k < n; k++) {
print.push_back({k, i});
}
i += n;
goto label;
} else {
label:
int mid = (i+j)/2;
int d = min(mid - i + n, j + n - mid);
int temp = max(0, n - 2 * (n - d));
for (int k = (n-temp)/2; k < (n+temp)/2; k++) {
print.push_back({k, mid});
}
ans += temp;
if ((i+j) % 2 && n % 2) {
if (temp > 0) {
mid++;
while (temp > 1)
mid++, temp-=2;
print.push_back({n/2, mid});
ans++;
}
}
}
cout << ans << '\n';
for (auto [i,j] : print) {
if (!flip)
cout << i+1 << ' ' << j+1 << '\n';
else
cout << j+1 << ' ' << i+1 << '\n';
}
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3768kb
input:
2 5
output:
6 1 1 1 5 2 1 2 5 1 3 2 3
result:
ok n: 2, m: 5, bishops: 6
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3604kb
input:
5 5
output:
9 1 1 2 1 3 1 4 1 5 1 2 5 3 5 4 5 3 7
result:
wrong answer Integer parameter [name=y] equals to 7, violates the range [1, 5]