这死循环怎么搞的只有60分

P1319 压缩技术

caojiaming @ 2022-10-25 12:13:18

#include <bits/stdc++.h>
using namespace std;
int n,cur=0;
int a0,a1;
int main()
{
    cin>>n;
    while(cin>>a0&&cin>>a1)
    {
        for(int i=1;i<=a0;i++)
        {
            cout<<"0";
            cur++;
            if(cur%n==0)
            {
                cout<<"\n";
            }
        }
        for(int i=1;i<=a1;i++)
        {
            cout<<"1";
            cur++;
            if(cur%n==0)
            {
                cout<<"\n";
            }
        }
    }
    return 0;
}

by caojiaming @ 2022-10-25 12:57:30

求助,我的#2#7#9#10WA


by caojiaming @ 2022-10-25 13:02:56

急需回复!快!快!快!


by Apress @ 2022-10-25 13:20:37

@caojiaming 不好意思,没时间看你的了,AC代码发给你:

#include<bits/stdc++.h>

using namespace std;
int n,k,map114[40100],key=0,f=1;
int main(){
    cin>>n;
    while(cin>>k){
        while(k--)
        map114[++f]=key%2;
        key++;
    }
    for(int i=1;i<=n;i++,puts(""))
      for(int j=1;j<=n;j++)  cout<<map114[n*(i-1)+j+1];
    return 0;
}

by caojiaming @ 2022-10-25 14:36:42

那我的为什么不对呢


|