TYxxj @ 2020-11-15 11:11:07
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
int x,y;
string s;
char a;
int main(){
cin>>s;
cout<<s.size()<<" ";
if(s[0]=='0')x++;
if(s[0]=='1')y++;
for(int i=1;i<s.size();i++){
if(s[i]==s[i-1]&&s[i]=='0')x++;
if(s[i]==s[i-1]&&s[i]=='1')y++;
if(s[i]!=s[i-1]&&s[i]=='1')cout<<x<<" ",y++,x=0;
if(s[i]!=s[i-1]&&s[i]=='0')cout<<y<<" ",x++,y=0;
}
a=s[s.size()-1];
for(int i=1;i<s.size();i++){
cin>>s;
if(s[0]==a&&s[0]=='0')x++;
if(s[0]==a&&s[0]=='1')y++;
if(s[0]!=a&&s[0]=='1')cout<<x<<" ",y++,x=0;
if(s[0]!=a&&s[0]=='0')cout<<y<<" ",x++,y=0;
for(int j=1;j<s.size();j++){
if(s[j]==s[j-1]&&s[j]=='0')x++;
if(s[j]==s[j-1]&&s[j]=='1')y++;
if(s[j]!=s[j-1]&&s[j]=='1')cout<<x<<" ",y++,x=0;
if(s[j]!=s[j-1]&&s[j]=='0')cout<<y<<" ",x++,y=0;
}
a=s[s.size()-1];
if(i==s.size()-1&&s[s.size()-1]=='0')cout<<x<<" ",x++,y=0;
if(i==s.size()-1&&s[s.size()-1]=='1')cout<<y<<" ",y++,x=0;
}
}
by qinyihao @ 2020-11-15 11:12:57
@19ty06 评测机死了,等会提交吧
by TYxxj @ 2020-11-15 11:16:02
谢谢