-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path1287A.cpp
48 lines (43 loc) · 899 Bytes
/
1287A.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
/*
* Author: Rushi Vachhani
* Platform: Codeforces
* Problem_ID: 1287A
* Language: C++
*/
#include<bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
vector<char> s;
bool input_flag = false;
for(int i=0; i<n; i++) {
char temp;
cin >> temp;
if(temp=='A') { input_flag = true; }
if(input_flag==true) { s.push_back(temp); }
else { continue; }
}
if(s.size()==0 || s.size()==1) { cout<<0<<"\n"; return; }
int ans = 0, count = 0;
for(int i=0; i<s.size(); i++) {
if(s[i]=='A') {
ans = max(ans, count);
count = 0;
}
else { count++; }
}
ans = max(ans, count);
cout<<ans<<"\n";
return;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while(t--) {
solve();
}
return 0;
}