-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path712A.cpp
More file actions
73 lines (68 loc) · 1.36 KB
/
712A.cpp
File metadata and controls
73 lines (68 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <iostream>
#include <string>
#include <streambuf>
#include <fstream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <map>
#include <set>
#include <stdlib.h>
#include <cstdio>
#include <vector>
#include <queue>
#include <utility>
using namespace std;
#define pi acos(-1.0)
#define N 1000000
#define ll long long
using namespace std;
char arr[105];
vector <ll> order;
int main()
{
ll x,y,a,b,n,e;
ll grp=0,count=0,flag=0;
scanf("%lld %s",&n,&arr);
for(ll i=0;i<strlen(arr);i++)
{
if(arr[i]== 'B')
{
if(i==0)
{
count++;
flag=1;
grp++;
}
else if(i>0 && arr[i-1]!='B')
{
count++;
flag=1;
grp++;
}
else
{
count++;
flag=1;
}
}
else
{
order.push_back(count);
flag=0;
count=0;
}
}
if(arr[strlen(arr)-1]=='B')
order.push_back(count);
cout << grp << endl;
for(ll i=0;i<order.size();i++)
{
if(order[i]!=0)
cout << order[i] << " ";
}
return 0;
}