Help me with PSHOT

#include<bits/stdc++.h>
using namespace std;
int main()
{

int t;

cin>>t;
while(t--)
    {

 	int n;
cin>>n;
string s;
cin>>s;
int ra=n;
int a=0,b=0,i=0,att=0;
while(i<2*n)

{
    if(s[i]=='1')
        a++;

    if(s[i+1]=='1')
        b++;
    att=att+2;

if(abs(a-b)>(2*n-att)/2)
    break;
    i=i+2;
    }
cout<<att<<endl;



}

}

You are checking only when both have played. There can be case that winner is decided after first one has played.
https://www.codechef.com/viewsolution/31980355

1 Like