QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#98756#6309. AqrestkwillWA 1ms12824kbC++142.2kb2023-04-19 22:10:342023-04-19 22:10:35

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-19 22:10:35]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:12824kb
  • [2023-04-19 22:10:34]
  • 提交

answer

#include <bits/stdc++.h>

const int N = 1100;

int a[N][N], b[N][N];

inline std::pair<int, int> Solve(int n, int m) {
    if (n < 4 && m < 4) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m; ++j) std::cout << 1;
            std::cout << '\n';
        }
        return std::make_pair(-1, -1);
    }
    if (n == 2 || m == 2) return std::make_pair(2, 2);
    int N = n % 4, M = m % 4;
    if (N == 0 || M == 0) return std::make_pair(0, 0);
    if (n == 3 || m == 3) {
        int T = n == 3 ? m : n;
        std::vector<std::vector<int> > a(3, std::vector<int>(T + 10));
        for (int i = 0; i < T; i += 4) a[0][i + 1] = a[1][i + 3] = a[2][i + 3] = 1;
        if (n == 3) {
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) std::cout << !a[i][j];
                std::cout << '\n';
            }
        } else {
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) std::cout << !a[j][i];
                std::cout << '\n';
            }
        }
        return std::make_pair(-1, -1);
    }
    if (N == 1 || M == 1) return std::make_pair(2, 2);
    return std::make_pair(3, 1);
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr), std::cout.tie(nullptr);
    a[0][0] = a[1][2] = a[2][1] = a[3][3] = 1;
    for (int i = 0; i < 4; ++i) for (int j = 4; j < N; ++j) a[i][j] = a[i][j - 4];
    for (int i = 4; i < N; ++i) for (int j = 0; j < N; ++j) a[i][j] = a[i - 4][j];
    for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) b[i][j] = a[i][j];
    for (int i = 0; i < N; ++i) for (int j = 1; j < N; ++j) b[i][j] += b[i][j - 1];
    for (int i = 1; i < N; ++i) for (int j = 0; j < N; ++j) b[i][j] += b[i - 1][j];
    int T;
    std::cin >> T;
    while (T--) {
        int n, m;
        std::cin >> n >> m;
        auto [x, y] = Solve(n, m);
        if (x == -1 && y == -1) continue;
        x += 4, y += 4;
        std::cout << b[x + n - 1][y + m - 1] - b[x + n - 1][y - 1] - b[x - 1][y + m - 1] + b[x - 1][y - 1] << '\n';
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m; ++j) std::cout << !a[i + x][j + y];
            std::cout << '\n';
        }
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 12824kb

input:

3
2 2
3 4
3 8

output:

11
11
3
0111
1101
1011
6
01110111
11011101
10111011

result:

wrong answer Integer parameter [name=ans] equals to 11, violates the range [0, 4] (test case 1)