QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#97614#6309. AqreayerszWA 2ms3340kbC++202.2kb2023-04-17 15:28:252023-04-17 15:28:27

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-17 15:28:27]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3340kb
  • [2023-04-17 15:28:25]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

int solve();

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

const int N = 1005;

int ans[N][N];
int n, m;
int cnt;

const int d[5] = {0, 4, 2, 3, 1};

void print() {
    cnt = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cnt += ans[i][j];
        }
    }
    cout << cnt << "\n";
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cout << ans[i][j];
        }
        cout << "\n";
    }
}

int solve() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            ans[i][j] = 0;
        }
    }
    if (n <= 3 && m <= 3) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                ans[i][j] = 1;
            }
        }
        print();
        return 0;
    }
    if ((n == 3 && m == 4) || (n == 4 && m == 3)) {
        for (int i = 1; i <= 3; i++) {
            for (int j = 1; j <= 3; j++) {
                ans[i][j] = 1;
            }
        }
        print();
        return 0;
    }
    if (n <= 3) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if (j % 2 == 1) {
                    ans[i][j] = 1;
                } else {
                    if (((j / 2) % 2 == 0 && i == 1) ||
                        ((j / 2) % 2 == 1 && i == n)) {
                        ans[i][j] = 1;
                    }
                }
            }
        }
        print();
        return 0;
    }
    if (m <= 3) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if (((i / 2) % 2 == 0 && j == 1) ||
                    ((i / 2) % 2 == 1 && j == m)) {
                    ans[i][j] = 1;
                }
            }
        }
        print();
        return 0;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            int x = (i - 1) % 4 + 1, y = (j - 1) % 4 + 1;
            if (d[x] != y) {
                ans[i][j] = 1;
            }
        }
    }
    print();
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3340kb

input:

3
2 2
3 4
3 8

output:

4
11
11
9
1110
1110
1110
16
10111011
10101010
11101110

result:

wrong answer ans finds a larger answer (test case 3)