QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#181832#7178. BishopsUSP_USP_USP#WA 1ms3376kbC++201.1kb2023-09-17 01:30:092023-09-17 01:30:10

Judging History

你现在查看的是最新测评结果

  • [2023-09-17 01:30:10]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3376kb
  • [2023-09-17 01:30:09]
  • 提交

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)