-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA.cpp
More file actions
35 lines (33 loc) · 836 Bytes
/
A.cpp
File metadata and controls
35 lines (33 loc) · 836 Bytes
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
#include <bits/stdc++.h>
using namespace std;
#define ll long long
using namespace std;
#define fast {ios_base::sync_with_stdio();}
#define T int T;cin>>T;while(T--)
#define ld long double
#define yes {cout<<"YES"<<endl;return;};
#define no {cout<<"NO"<<endl;return;};
signed main() {
T {
int n;
cin >> n;
string s;
cin >> s;
int ans = 0;
while (true) {
bool flag = 0 ;
for (int i = 0; i < n - 1; i++) {
if (s[i] == 'A') {
if (s[i + 1] == 'P') {
s[i+1]='A';
i++;
flag=1;
}
}
}
ans++;
if(!flag)break;
}
cout<<ans-1<<endl;
}
}