Too short on line one??案例过了呀

P1319 压缩技术

qwq57 @ 2024-12-22 20:27:10

#include<iostream>
using namespace std;

int main()
{
    int n; cin >> n;
    int m = n * n;

    bool flag = 0;
    int state = 0;
    int a; 
    while (cin >> a)
    {
            if (flag)
            {
                for (int i = 1; i <= a; i++)
                {
                    if (state % n == 0)cout << endl;
                    cout << 1;
                    state++;
                }
            }
            else
            {
                for (int i = 1; i <= a; i++)
                {
                    if (state % n == 0)cout << endl;
                    cout << 0;
                    state++;
                }
            }

        flag = !flag;
    }

    return 0;
}

by qwq57 @ 2024-12-22 20:35:47

#include<iostream>
using namespace std;

int main()
{
    int n;cin>>n;
    int m=n*n;

    bool flag=0;
    int state=0;
    while(m)
    {
        int a;cin>>a;
        for(int i=1;i<=a;i++)
        {
            if(flag)
            {
                if(state%n==0)cout<<endl;
                cout<<1;
                state++;
            }
            else
            {
                if(state%n==0)cout<<endl;
                cout<<0;
                state++;
            }
        }
        flag=!flag;
        m-=a;
    }

    return 0;
}

by gaohuashengtx @ 2024-12-22 21:13:51

#include<bits/stdc++.h>
using namespace std;
int main() {
    int n,k=0,x,sum=0;
    cin>>n;
    for(int i=1;;i++){
      cin>>x;
      sum=sum+x;
      for(int j=1;j<=x;j++){
        if(i%2!=0)cout<<0;
        else cout<<1;
        k++;
        if(k%n==0) cout<<endl;
      }
      if(sum==n*n) break;
    }
    return 0;
}

@qwq57 事实上不用想太复杂 这题就是压缩然后转换


by gaohuashengtx @ 2024-12-22 21:14:38

你过了吗


by qwq57 @ 2024-12-22 21:35:06

@gaohuashengtx 没过哥 全wa说too short on line 1 搞不懂,而且这题的续集也是一个情况


by qwq57 @ 2024-12-22 21:38:35

@gaohuashengtx 感觉跟你思路一样啊,为啥不对


|