QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#505155#7178. BishopsEsoulingML 0ms3816kbC++201.7kb2024-08-04 20:51:252024-08-04 20:51:26

Judging History

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

  • [2024-08-04 20:51:26]
  • 评测
  • 测评结果:ML
  • 用时:0ms
  • 内存:3816kb
  • [2024-08-04 20:51:25]
  • 提交

answer

#include <bits/stdc++.h>

using loint = long long;
using db = double;

void solve() {
    
    int n, m;
    std::cin >> n >> m;
    int inv = 0;
    if (n > m) {
        std::swap(n, m);
        inv = 1;
    }
    std::vector<std::pair<int, int>> ans;
    if (n == m) {
        for (int i = 1; i <= n; i ++) {
            ans.push_back({i, 1});
        }
        for (int i = 2; i <= n - 1; i ++) {
            ans.push_back({i, m});
        }
    } else if (n & 1) {
        for (int i = 1; i <= n; i ++) {
            ans.push_back({i, 1});
        }
        for (int i = 1; i <= n; i ++) {
            ans.push_back({i, m});
        }
        int l = n / 2 + 2, r = m - (n / 2 + 1);
        for (int j = l; j <= r; j ++) {
            ans.push_back({n / 2 + 1, j});
        }
    } else {

        for (int i = 1; i <= n; i ++) {
            ans.push_back({i, 1});
        }
        for (int i = 1; i <= n; i ++) {
            ans.push_back({i, m});
        }
        int l = n / 2 + 2, r = m - (n / 2 + 1);
        for (int j = l; j <= n / 2; j += 2) {
            ans.push_back({n / 2, j});
            ans.push_back({n / 2 + 1, j});
        }
        for (int j = r; j >= n / 2 + 1; j -= 2) {
            ans.push_back({n / 2, j});
            ans.push_back({n / 2 + 1, j});
        }

    }

    std::cout << ans.size() << '\n';
    std::vector a(n + 5, std::vector<int> (m + 5, 0));
    for (auto &[x, y] : ans) {
        if (inv) std::swap(x, y);
        std::cout << x << ' ' << y << '\n';
    }
}

int main() {

    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);

    solve();

    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3816kb

input:

2 5

output:

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

result:

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

Test #2:

score: 0
Accepted
time: 0ms
memory: 3524kb

input:

5 5

output:

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

result:

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

Test #3:

score: -100
Memory Limit Exceeded

input:

100000 100000

output:


result: