百思不得其解

P1319 压缩技术

liu12073_ @ 2023-10-14 21:58:46

#include<iostream>
using namespace std;
int main() {
    int n, q[210], r = 0;
    cin >> n;
    for (int i = 1; i <= n * 2; i++) cin >> q[i];
    for (int j = 1; j <= n * 2; j++) {
        for (int k = 1; k <= q[j]; k++) {
            if (j % 2) {
                if (!(r % n)) cout << endl;
                cout << 0;
                r++;
            } else {
                if (!(r % n)) cout << endl;
                cout << 1;
                r++;
            }
        }
    }
    return 0;
}

样例没问题,就是不知道为什么全部WA


by six_one @ 2023-10-14 22:02:48

n^2或许


by six_one @ 2023-10-14 22:05:35

哦,我的意思是,循环读入的边界不应该是2n而应该是在读入的和等于n^2时结束


|