-
Notifications
You must be signed in to change notification settings - Fork 0
/
VILTRIBE.cpp
48 lines (45 loc) · 1006 Bytes
/
VILTRIBE.cpp
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
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t=0; cin>>t;
while(t--)
{
string s;
cin>>s;
int len = s.length();
char ch[len]; int pos[len];
int ac=0, bc=0;
int k=-1;
for(int i=0; i<len; i++)
{
if(s[i] != '.')
{
ch[++k]=s[i];
pos[k]=i;
if(s[i]=='A')
++ac;
else
++bc;
}
}
for(int i = 0; i<k; i++)
{
if(ch[i]=='A' && ch[i+1]== 'A')
{
ac = ac + (pos[i+1] - pos[i]);
ac-=1;
}
}
for(int i = 0; i<k; i++)
{
if(ch[i]=='B' && ch[i+1]== 'B')
{
bc = bc + (pos[i+1] - pos[i]);
bc-=1;
}
}
cout<<ac<<" "<<bc<<endl;
}
return 0;
}