QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#250112 | #7178. Bishops | kilo_tobo_tarjen# | WA | 0ms | 3612kb | C++14 | 919b | 2023-11-12 21:28:22 | 2023-11-12 21:28:23 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const char el = '\n';
typedef long long ll;
bool flp;
void submit(int x, int y) {
if (flp)
cout << y << ' ' << x << el;
else
cout << x << ' ' << y << el;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(15);
int n, m;
cin >> n >> m;
if (n == m) {
cout << n + m - 2 << el;
for (int i = 1; i < n; i++) submit(1, i);
for (int i = 1; i < n; i++) submit(n, i + 1);
return 0;
}
cout << n + m - 1 - (n % 2 == 0 && m % 2 == 0) << el;
if (n < m) {
flp = true;
swap(n, m);
}
for (int i = 1; i <= m; i++) submit(1, i);
for (int i = 1; i <= m; i++) submit(n, i);
int k = (m + 1) / 2;
if (m & 1) {
for (int i = k + 1; i <= n - k; i++) submit(i, k);
return 0;
}
for (int i = k + 2; i < n - k; i += 2) submit(i, k), submit(i, k + 1);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3608kb
input:
2 5
output:
6 1 1 2 1 1 5 2 5 1 3 2 3
result:
ok n: 2, m: 5, bishops: 6
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3612kb
input:
5 5
output:
8 1 1 1 2 1 3 1 4 5 2 5 3 5 4 5 5
result:
wrong answer Dif diagonals are not distinct