c语言为什么全部超时啊,在自己编译器上跑很快的啊

P1319 压缩技术

wan_qiu @ 2024-01-20 17:23:06

#include<stdio.h>
int dayin0(int x, int temp, int n)
{
    int i = 0;
    while (i < x)
    {
        if (temp % n == 0 && temp != 0)
            printf("\n");
        printf("0");
        temp++;
        i++;
    }
    return temp;
}
int dayin1(int x, int temp, int n)
{
    int i = 0;
    while (i < x)
    {
        if (temp % n == 0 && temp != 0)
            printf("\n");
        printf("1");
        temp++;
        i++;
    }
    return temp;
}

int main()
{
    int i = 0;
    char y;
    int b[1000] = { 0 };
    do
    {
        scanf("%d", &b[i]);
        i++;
    } while (y=getchar() != '\n');
    int n = b[0];
    i = 1;
    int temp = 0;
    while (temp < n * n)
    {
        if (i % 2 != 0)
            temp = dayin0(b[i], temp, n);
        if (i % 2 == 0)
            temp = dayin1(b[i], temp, n);
        i++;
    }
    return 0;
}

|