求助大佬,为什么会re,不知道问题出在哪里

P1319 压缩技术

wuzixianhaoyoucha @ 2023-03-19 21:56:47


#include <iostream>
using namespace std;

int a[201];     //一行中的每个数

int main() {
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 1; i <= n * n; i++) {
        cin >> a[i];
        if (i % 2 != 0) {
            for (int j = 1; j <= a[i]; j++) {
                cout << 0; sum++; if (sum % n == 0) cout << "\n";
            }
        }
        else {
            for (int k = 1; k <= a[i]; k++) {
                sum++; cout << 1; if (sum % n == 0) cout << "\n";
            }
        }
    }
    return 0;
}

by y6hz @ 2023-05-02 15:42:05

数组开小了…… 看题:

说明/提示 数据保证, 3≤N≤200。


by y6hz @ 2023-05-02 15:43:05

所以a至少要开200*200=40000


|