全部超时,请问怎么优化啊
查看原帖
全部超时,请问怎么优化啊
462477
wenboooo楼主2021/1/22 13:55
#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;
}


2021/1/22 13:55
加载中...