# Practice Beginner PROXYC problem with code

#include
#include <math.h>
#include <stdio.h>
using namespace std;
int main()
{
int T;
cin>>T;
while(T–){
int D,d,ctrA=0,ctr=0,ctrP=0;
int minreq=0,req=0;char S[1000];
cin>>D;
if(D<=200){
for(d=0;d<D;d++)cin>>S[d];
for(d=0;d<D;d++)
{
if((S[d])==‘A’)
ctrA++;
}
ctrP=D-ctrA;
for(d=2;d<D-2;d++)
{
if((S[d]==‘A’)&&(S[d-1]==‘P’||S[d-2]==‘P’)&&(S[d+1]==‘P’||S[d+2]==‘P’))
{ctr++;}
}
req=ceil(0.75*D);
if((ctr+ctrP)<req)
minreq=-1;
else if(((ctr+ctrP)>=req)&&(ctrP<=req)){
minreq=req-ctrP;
}
}
cout<<minreq<<endl;
}
return 0;
}

Assuming this is your solution: it fails on the following testcase:

``````1
437
AAAAAPAPPAAAPAAAAPAAAAPPPPAAPAAPAAAAAPAPPPPPAAAPPPAPAAAAPAAPPAPPAAAAAAAAAAPAAAAAPAAPAAAAPPAAAPAAAAAAAAAAPAPPAPAAAAAAPPPAAPPAPAPPPAAAPPAPPAPAPAAAPAAPAPAAAAAAPPAAAAAPPPPAAAAAPAAAAAAAPPPAAAPAPAPAAPAPAAAAPPAPAAAAPPAPPAPPPAPPAPAPPAAPAAPPAPAPAAPAPPPAAPPPAPPPPAAPAAPAPAAAPPAAPAAPAAAPAAAAAAPAAAAPAAAPAAAAPAAAPAPPPPPPPAAPAAAPPAPAPAAPAPAPAPPAAAPAAAPAPPAPAPPAPPPPPAAPAPPAAPPPAAAPAAAAPPAAAAPPPAPAPAPPPAAAPAPAPAPAAAAPPAPPPPPPPAAAPPAAPAPPPAPAAPPPPPAAP
``````

(the answer should be `-1`).

1 Like

why do you think it fails?
Like I am not able to find any errors in my code

That’s for you to find out - you’ve got a nice, 100%-reproducible testcase to work with

1 Like