2 solutions

  • 1
    @ 2024-11-26 21:12:55
    #include<bits/stdc++.h>
    typedef long long ll;
    using namespace std;
    const int N=10010;
    int n,a,t,m;
    int main(){
    	
    	cin.sync_with_stdio(false);
    	ios::sync_with_stdio(0);
    	cin.tie(0);cout.tie(0);
        cin>>n;
        while(cin>>a){
            if(a){
                for(int i=1;i<=a;i++){
                    if(t==n){
                        cout<<'\n';
                        t=0;
                    }
                    cout<<m;
                    t++;
                }
            }
            m=(m==1?0:1);
        }
        
        return 0;
    }
    

    祝大家AC!!!

    • 0
      @ 2024-10-29 17:50:28
      #include<bits/stdc++.h>
      using namespace std;
      int main(){
      	int n,cnt=0,cnt1=0;
      	int sum[100000]={0},i=1;
      	cin>>n;
      	while(cnt1<n*n){
      		cin>>sum[i];
      		cnt1+=sum[i];
      		i++;
      	}
      	for(int j=1;sum[j]!=0;j++){
      		for(int l=1;l<=sum[j];l++){
      			if(j%2==1){
      				if(cnt>=n){
      					cout<<endl;
      					cnt-=n;
      				}
      				cout<<0;
      			}else{
      				
      				if(cnt>=n){
      					cout<<endl;
      					cnt-=n;
      				}
      				cout<<1;
      			}
      			cnt++;
      		}
      	}
      }
      
      
      
      • 1

      Information

      ID
      421
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      5
      Tags
      (None)
      # Submissions
      90
      Accepted
      33
      Uploaded By