红名求助红题
查看原帖
红名求助红题
1045932
Na1L0n9楼主2025/8/29 10:53
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a[40010], x = 0, cnt = 0;
    string s;
    bool flag = 1;
    int t = 0;
    while (cin >> s) {
    	x += s.length();
    	for (int i = 0; i < s.length(); i++) {
    		a[i + 1 + t] = s[i] - 48;
		}
		t += s.length();
	}
	cout << sqrt(x) << " ";
	int tmp = a[1];
	for (int i = 1; i <= x; i++) {
		cnt++;
		if (a[i] != tmp) {
			tmp = a[i];
			cout << cnt << " ";
			cnt = 0;
		}
		if (i == x && a[i] == tmp) {
			cout << cnt + 1;
		}
	}
    return 0;
}

10分hhh

2025/8/29 10:53
加载中...