PenaltyShoot 2(Contest 2)

#include

using namespace std;

int main() {
int t;
cin>>t;
while(t>0){
int n,c=0,d=0;
cin>>n;
string s;
cin>>s;
for(int i=0;i<2n;i+2){
d++;
c=c+s[i+1]-s[i];
if(abs©>n-d){
cout<<2
d<<endl;
break;
}
else if(d==n){
cout<<2*n<<endl;
}

    }
    t--;
}
return 0;

}
Where did I go wrong??Someone plzzz help

format your code or give link to your submission

You should write pseudo code instead of pasting your actual code. The problem with your code might be is that in some cases it doesn’t look at B’s score and gives an output ‘n’ instead on n + 1
while there are some cases that don’t require you to look at B’s outcome after a point.
Another problem might be is your output is 2d and d being an int has to be an even number , which is incorrect. consider this case - ( n = 5 ) 1 0 1 0 1 1 0 1 0 . The output is determined at 5 which in your case would result in WA. For extra help here is my submission - https://www.codechef.com/viewsolution/33282206 .

1 Like

format your code or share a link. Don’t copy-paste it here