全wa求助

P1319 压缩技术

Hopoyage @ 2023-09-30 20:46:09

#include<iostream>
using namespace std;
int n,count = 0,temp,sum = 1;
int main(){
    cin >> n;
    while(sum <= n*n){
        cin >> temp;
        if(sum % 2 != 0){
            for(int i = 0;i < temp;i++){
                cout << 0;
                count++;
                if(count == n){cout << endl;count=0;}
            }
            sum++;
        }else
        if(sum % 2 == 0){
            for(int i = 0;i < temp;i++){
                cout << 1;
                count++;
                if(count == n){cout << endl;count=0;}
            }
            sum++;
        }
    }
    return 0;
}

by drinktowind @ 2023-09-30 21:01:54

#<bits/stdc++.h>
using namespace std;
int main ()
{
    int n,x,f=0,sum=0;
    cin>>n;
    while(cin>>x)
    {
        while(x--)
        {
            cout<<f;
            sum++;
            if(sum%n==0)
                cout<<endl;
        }
        f=!f;
        if(sum==n*n)
            return 0;
    }
}

|