QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#181800#7178. BishopsUSP_USP_USP#WA 0ms3548kbC++201.1kb2023-09-17 00:44:202023-09-17 00:44:20

Judging History

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

  • [2023-09-17 00:44:20]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3548kb
  • [2023-09-17 00:44:20]
  • 提交

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();
}

Details

Tip: Click on the bar to expand more detailed information

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