QOJ.ac
QOJ
ID | 提交记录ID | 题目 | Hacker | Owner | 结果 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|
#675 | #440111 | #7178. Bishops | shenzhiyan | cyb1010 | Failed. | 2024-06-13 14:46:34 | 2024-06-13 14:46:34 |
详细
Extra Test:
Accepted
time: 0ms
memory: 3760kb
input:
1 1
output:
1 1 1
result:
ok n: 1, m: 1, bishops: 1
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#440111 | #7178. Bishops | cyb1010 | AC ✓ | 16ms | 5340kb | C++14 | 1.6kb | 2024-06-13 09:14:44 | 2024-06-13 09:14:44 |
answer
/**
* @author : cyb1010
* @date : 2024-06-13 08:10:59
* @file : bishop.cpp
*/
#include <bits/stdc++.h>
using namespace std;
#define fo(s) freopen(s ".in", "r", stdin), freopen(s ".out", "w", stdout)
#define fi first
#define se second
#define ALL(v) (v).begin(), (v).end()
#define SZ(v) int(v.size())
typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<pair<int, int>> vp;
void ckmx(int &x, int y) { x < y && (x = y); }
void ckmn(int &x, int y) { x > y && (x = y); }
int __, n, m;
vp ans;
vp solve(int n, int m) {
vp res;
if (n > m) {
res = solve(m, n);
for (auto &[x, y] : res) swap(x, y);
return res;
}
if (n & 1) {
for (int i = 1; i <= n; i++)
res.emplace_back(i, 1), res.emplace_back(i, m);
int rw = n / 2 + 1;
for (int i = rw + 1; i + rw <= m; i++) res.emplace_back(rw, i);
return res;
}
for (int i = 1; i <= n; i++) res.emplace_back(i, 1), res.emplace_back(i, m);
int rw = n / 2;
for (int i = rw + 2; i + rw < m; i += 2)
res.emplace_back(rw, i), res.emplace_back(rw + 1, i);
return res;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> m;
if (n == m) {
if (n == 1) return cout << "1\n1 1\n", 0;
cout << n * 2 - 2 << '\n';
for (int i = 1; i < n; i++)
cout << i << " 1\n" << i << ' ' << n << '\n';
return 0;
}
vp ans = solve(n, m);
cout << SZ(ans) << '\n';
for (auto [x, y] : ans) cout << x << ' ' << y << '\n';
return 0 ^ __ ^ 0;
}