求助,VS上N=40也很快,结果洛谷全tle
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<math.h>
int main()
{
int arr[40005] = { 0 };
int count = 0;
char x = 0;
for (int i = 0; 1; i++)
{
x = getchar();
if (x != '\n')
{
count++;
arr[i] = x - '0';
}
else if (x == '\n')
break;
}
for (int i = count; i < count * count; i++)
{
x = getchar();
if (x != '\n')
arr[i] = x - '0';
else
arr[i] = getchar() - '0';
}
printf("%d ", count);
int b = 0;
for (int a = 0; b < count * count;a++ )
{
int k = 0;
if (a % 2 == 0)
{
while (arr[b] == 0)
{
if (b == count*count)
break;
k++;
b++;
}
printf("%d ", k);
}
else
{
while (arr[b] == 1)
{
if (b == count*count)
break;
k++;
b++;
}
printf("%d ", k);
}
}
return 0;
}