forked from sanjiv1705/codechef
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjune_1_2.cpp
More file actions
64 lines (49 loc) · 1020 Bytes
/
june_1_2.cpp
File metadata and controls
64 lines (49 loc) · 1020 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t , j ;
cin>>t;
for(j=0 ; j<t ; j++ )
{
float d ;
int i;
cin>>d;
string s;
cin>>s;
float c= 0;
for(int k= 0 ; k<d;k++)
{
if(s[k]=='P')
c++;
}
if((c/d)>=0.75)
cout<<0<<endl;
else{
int m = 0;
int l =0;
float f=0;
for(int k= 0 ; k<d;k++)
{
if(s[k]=='P')
f++;
if((f/d)>=0.75)
{int m = 1;
break;
}
else{
for(i= 2 ; i<d-2; i++)
{
if(s[i]=='A')
{
if(((s[i-2]||s[i-1])&&(s[i+1]||s[i+2])=='P'))
{
l++;} }}}
}
if(m ==1)
cout<<l<<endl;
else
cout<<-1<<endl;
}
}}