压缩技术(续集版)过了,压缩技术没过
查看原帖
压缩技术(续集版)过了,压缩技术没过
1356734
huyouxi楼主2025/1/17 21:28

代码如下

#include <bits/stdc++.h>

using namespace std;

char a, b = '0';
int n, ans[1000001], zz = 1;

int main() {
    while (cin >> a) {
        n++;
        if (a == b) {
            ans[zz]++;
        } else {
            ans[++zz]++;
            b = a;
        }
    }
    cout << sqrt(n);
    for (int i = 1; i <= zz; i++) {
        cout << " " << ans[i];
    }
    return 0;
}
2025/1/17 21:28
加载中...