全部超时,请问怎么优化啊

P1320 压缩技术(续集版)

wenboooo @ 2021-01-22 13:55:48

#include <stdio.h>
int main()
{
    int a,b=0,c=0,x1,x2=0,m,n;
    char h[40000];
    do
    {
        for(a=b;;a++)
        {
            scanf("%c",&h[a]);
            if(a==2*b)
                c=b;
            if(h[a]=='\n')
                break;

        }b=a;
    }while(b!=c*c);
    printf("%d ",c);
    do
    {
        for(x1=x2,m=0;;x1++)
        {
            if(h[x1]=='0')
            {
                m++;
                continue;
            }
            printf("%d ",m);
            break;
        }
        for(x2=x1,n=0;;x2++)
        {
            if(h[x2]=='1')
            {
                n++;
                continue;
            }
            printf("%d ",n);
            break;
        }
    }while(x2<b);
    return 0;
}

|