-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPROXYC.cpp
More file actions
38 lines (32 loc) · 728 Bytes
/
PROXYC.cpp
File metadata and controls
38 lines (32 loc) · 728 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
36
37
38
#include <bits/stdc++.h>
using namespace std;
double d,P,ans,p,f=4.0,cnt;
string s;
int main(){
int t;
cin>>t;
while(t--){
cin>>d;
cin>>s;
cnt=0;
P=0;
for(int i=2;i<d-2;i++){
if( s[i]=='A' && (s[i-1]=='P'||s[i-2]=='P') && (s[i+1]=='P' || s[i+2]=='P') ){
cnt++;
}
}
for(int i=0;i<d;i++){
if( s[i]=='P' ){
P++;
}
}
ans=(((double)(3.0*d-4.0*P))/(double)f );
if(cnt>=ans){
cout<<max((int)ceil(ans),0)<<endl;
}else{
cout<<"-1"<<endl;
}
}
//cout<<ans<<" "<<cnt<<endl;
return 0;
}