QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#97613#6309. AqreayerszWA 0ms3308kbC++232.2kb2023-04-17 15:26:442023-04-17 15:26:45

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:26:45]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3308kb
  • [2023-04-17 15:26:44]
  • 提交

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3308kb

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)