QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#181800 | #7178. Bishops | USP_USP_USP# | WA | 0ms | 3548kb | C++20 | 1.1kb | 2023-09-17 00:44:20 | 2023-09-17 00:44:20 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define pb push_back
void dbg_out() { cerr << endl; }
template <typename H, typename... T>
void dbg_out(H h, T... t) { cerr << ' ' << h; dbg_out(t...); }
#define dbg(...) { cerr << #__VA_ARGS__ << ':'; dbg_out(__VA_ARGS__); }
int n, m;
void solve () {
cin >> n >> m;
bool troca = false;
if (n > m) swap (n, m), troca = true;
vector<pair<int, int>> ans;
for (int y = 1; y <= m; y += n) {
for (int x = 1; x <= n; x++) ans.pb ({x, y});
if (y + n > m) {
// se estourou
int fim = m - y;
int lim_cima = n - fim, lim_baixo = 1 + fim;
for (int j = lim_cima + 1; j < lim_baixo; j++) ans.pb ({j, y});
}
}
cout << ans.size () << "\n";
for (auto [x, y] : ans) {
if (troca) cout << y << " " << x << "\n";
else cout << x << " " << y << "\n";
}
}
signed main() {
ios::sync_with_stdio(false); cin.tie(0);
solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
input:
2 5
output:
6 1 1 2 1 1 3 2 3 1 5 2 5
result:
ok n: 2, m: 5, bishops: 6
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3548kb
input:
5 5
output:
8 1 1 2 1 3 1 4 1 5 1 2 1 3 1 4 1
result:
wrong answer Sum diagonals are not distinct