QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#181832 | #7178. Bishops | USP_USP_USP# | WA | 1ms | 3376kb | C++20 | 1.1kb | 2023-09-17 01:30:09 | 2023-09-17 01:30:10 |
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__); }
void dfs (int n, int m, vector<pair<int, int>> &ans) {
if (n <= 0 || m <= 0) return;
if (n < m) {
for (int i = 1; i <= n; i++) ans.pb ({i, m});
dfs (n, m - n, ans);
}
else if (m < n) {
for (int j = 1; j <= m; j++) ans.pb ({n, j});
dfs (n - m, m, ans);
}
else {
assert (n == m);
for (int i = 1; i < n; i++) ans.pb ({i, m}), ans.pb ({i, 1});
}
}
void solve () {
int n, m;
cin >> n >> m;
vector<pair<int, int>> ans;
dfs (n, m, ans);
cout << ans.size () << "\n";
for (auto [x, y] : ans)
cout << x << " " << y << "\n";
}
signed main() {
ios::sync_with_stdio(false); cin.tie(0);
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3376kb
input:
2 5
output:
5 1 5 2 5 1 3 2 3 2 1
result:
wrong answer Participant's answer is not optimal (5 < 6)