Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n,c=0,z=0,x=0,i;
- vector<int>v;
- string str;
- cin>>n;
- cin.ignore(numeric_limits<streamsize>::max(),'\n');
- cin>>str;
- for(i=0; i<n; i++)
- {
- if(str[i]=='B')
- {
- if(str[i+1]=='B')
- {
- c++;
- }
- else if(str[i+1]!='B')
- {
- c++;
- v.push_back(c);
- z++;
- c=0;
- }
- }
- }
- cout<<z<<endl;
- for(i=0; i<v.size(); i++)
- {
- cout<<v[i]<<' ';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement