-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathangry_stu.cpp
More file actions
executable file
·55 lines (44 loc) · 1.18 KB
/
angry_stu.cpp
File metadata and controls
executable file
·55 lines (44 loc) · 1.18 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
// g++ angry_stu.cpp -o angry_stu && ./angry_stu
/*
*/
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL)
#define endl '\n'
#define ll long long int
using namespace std;
#define pii pair <ll , ll >
#define pb push_back
#define deb(x) cout << #x << " " << x << endl
#define deb2(x, y) cout << #x << " " << x << " " << #y << " " << y << endl
#define loop(n) for(int i = 0; i < n; i++)
int main(){
fastio;
int t;
cin >> t;
while(t--){
int n;
cin >> n;
string a;
cin >> a;
char q0, q1;
int start;
int ans;
for(int i = 1; i < n; i++){
q0 = a[i-1];
q1 = a[i];
if(q0 == 'A' && q1 == 'P'){
start = i;
}
else if(q0 == 'P' && q1 == 'A'){
int temp = i - start;
ans = ans > temp ? ans : temp;
start = -1;
}
}
if(start != -1){
int temp = n-start;
ans = ans > temp ? ans : temp;
}
cout << ans << endl;
}
}