90分,求救

P1319 压缩技术

JshGLJ @ 2023-09-24 14:28:12

#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;

    vector<int> compressed;
    int num;
    while (cin >> num) {
        compressed.push_back(num);
    }

    vector<vector<int>> matrix(N, vector<int>(N, 0));

    int row = 0, col = 0;
    for (int i = 1; i < compressed.size(); i++) {
        for (int j = 0; j < compressed[i]; j++) {
            matrix[row][col] = i % 2;
            if (col == N - 1) {
                row++;
                col = 0;
            } else {
                col++;
            }
        }
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << matrix[i][j];
        }
        cout << endl;
    }

    return 0;
}

by Modi_Portal @ 2023-09-24 14:40:40

emm...说实话好像没呢么复杂吧


|