Spirit_ZeroHeart @ 2023-11-19 20:25:14
样例过了,但是全1.2s超时,能不能在优化了,求大佬解答
int main()
{
int zz=1,a[40002]={0},n=0,count;
char c,d='0';
while((c=getchar())!='\n')
{
n++;
if(c==d)
a[zz]++;
else
a[++zz]++;
d=c;
}
count=n;
while(count!=n*n)
{
c=getchar();
if(c=='0'||c=='1')
{
if(c==d)
a[zz]++;
else
a[++zz]++;
d=c;
count++;
}
}
printf("%d ",n);
for(int i=1;i<zz;i++)
printf("%d ",a[i]);
printf("%d",a[zz]);
return 0;
}