QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#170835#7178. Bishopsucup-team1264#WA 13ms6744kbC++201.2kb2023-09-09 16:04:072023-09-09 16:04:36

Judging History

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

  • [2023-09-09 16:04:36]
  • 评测
  • 测评结果:WA
  • 用时:13ms
  • 内存:6744kb
  • [2023-09-09 16:04:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> vis_add(n + m + 1);
    vector<int> vis_sub(n + m + 1); // i + m + 1 - j
    vector<pair<int, int>> ans;
    auto add = [&](int i, int j, int parity) {
        if (!(1 <= i && i <= n && 1 <= j && j <= m)) return;
        if ((i + j) % 2 != parity) return;
        if (vis_add[i + j] || vis_sub[i + m + 1 - j]) { return; }
        vis_add[i + j] = 1, vis_sub[i + m + 1 - j] = 1;
        ans.emplace_back(i, j);
    };
    for (int i = 1; i <= m; i++)
        add(1, i, 0), add(2, i, 0), add(n - 1, i, 0), add(n, i, 0);
    for (int i = 1; i <= n; i++)
        add(i, 1, 0), add(i, 2, 0), add(i, m - 1, 0), add(i, m, 0);
    for (int i = m; i >= 1; i--)
        add(n, i, 1), add(n - 1, i, 1), add(2, i, 1), add(1, i, 1);
    for (int i = n; i >= 1; i--)
        add(i, m, 1), add(i, m - 1, 1), add(i, 2, 1), add(i, 1, 1);
    cout << ans.size() << "\n";
    for (auto [x, y] : ans)
        cout << x << " " << y << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3636kb

input:

2 5

output:

6
1 1
1 3
1 5
2 5
2 3
2 1

result:

ok n: 2, m: 5, bishops: 6

Test #2:

score: 0
Accepted
time: 1ms
memory: 3640kb

input:

5 5

output:

8
1 1
5 1
1 3
5 3
4 5
2 5
4 1
2 1

result:

ok n: 5, m: 5, bishops: 8

Test #3:

score: -100
Wrong Answer
time: 13ms
memory: 6744kb

input:

100000 100000

output:

199996
1 1
99999 1
1 3
99999 3
1 5
99999 5
1 7
99999 7
1 9
99999 9
1 11
99999 11
1 13
99999 13
1 15
99999 15
1 17
99999 17
1 19
99999 19
1 21
99999 21
1 23
99999 23
1 25
99999 25
1 27
99999 27
1 29
99999 29
1 31
99999 31
1 33
99999 33
1 35
99999 35
1 37
99999 37
1 39
99999 39
1 41
99999 41
1 43
9999...

result:

wrong answer Participant's answer is not optimal (199996 < 199998)