求助大佬们,70分

P1319 压缩技术

chenzher @ 2023-05-23 22:18:13

代码:(算了几遍觉得好像没啥问题啊)

#include<cstdio>
using namespace std;
int x,y;
int a[1001][1001];
int n,m0,m1;
int main()
{
    x=1,y=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int z=0;
        scanf("%d%d",&m0,&m1);
        y+=m0;
        if(y>=n)
        {
            x+=y/n;
            y=y-n*(y/n);
        }
        y+=m1;
        while(y>=n)
        {
            z=1;
            for(int j=y-m1+1;j<=n;j++)
            {
                a[x][j]=1;
            }
            for(int j=1;j<=y-n;j++)
            {
                a[x][j]=1;
            }
            x++;
            y-=n;
        }
        if(z==0)
        {
            for(int j=y-m1+1;j<=y;j++) a[x][j]=1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            printf("%d",a[i][j]);
        }
        printf("\n");
    }
    return 0;
}

by chenzher @ 2023-05-23 22:19:26

3,4,5没过


by zsh_haha @ 2023-05-23 22:51:37

@xuzichen2023 你有没有想过,要是输入样例的个数不是偶数个数呢?


by chenzher @ 2023-05-24 19:04:07

@zhangsenhao6728 能给个样例吗?


by cdxxmashaoyang @ 2023-07-10 09:15:22

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int Map[n*n+10];
    int Full;
    bool Key=false;
    int p=0;
    while(cin>>Full)
    {
        int i;
        for(i=p;i<p+Full;i++)
            Map[i]=Key;
        p=i;
        Key=!Key;
    }
    p=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cout<<Map[p];
            p++;
        }
        cout<<endl;
    }
    return 0;    
}

by cdxxmashaoyang @ 2023-07-10 09:16:33

https://www.luogu.com.cn/team/60983 麻烦加一下我的团队


|