70分救助
查看原帖
70分救助
1254203
LQZl楼主2024/7/28 13:48
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char a[4005],t;
    long long y=1;
    while(cin>>t)
    {
        if(t=='0'||t=='1'){
            a[y++]=t;
        }
    }
    y--;
    long long x=1;
    cout<<sqrt(y)<<' ';
    char jh='0';
    y++;
    while(x<y){
        long long cnt=0;
        while(a[x]==jh){
            cnt++; 
            x++;
            if(x>y)break;
        }
        cout<<cnt<<' ';
        if(jh=='0')jh='1';
        else jh='0';
    }
    return 0;
}

2024/7/28 13:48
加载中...