RT,n 的结果是 0。。。
#include <stdio.h>
#include <cmath>
#include <iostream>
int res[100005], sz;
int main()
{
char x, tf = '0';
int n = 0;
while (std::cin >> x)
{
n++;
if (x != tf)
sz++, res[sz]++, tf = x;
else
res[sz]++;
}
printf("%d", std::sqrt(n));
for (int i = 0; i <= sz; i++)
printf(" %d", res[i]);
}