i am getting correct output for the test case given in problem but getting WA on submisiion

#include
using namespace std;

int main() {
int t;
cin>>t;
while(t–)
{
int n,x=0;
cin>>n;
string s;
cin>>s;
int a=0,b=0,l = 2*n;
for(int i=0; i<l ; i++)
{
x++;
if(i%2 == 0)
{
if(s[i]==‘1’)
a +=1;
}
else
{
if(s[i]==‘1’)
b +=1;
}

     if(x%2==0)
     {
        if(x==l && a == b)
        {
            cout<<l<<"\n";
            break;
        }
       if(abs(a-b) > (l-x)/2)
       {
           cout<<x<<"\n";
           break;
       }
     }
   }
   
}
return 0;

}

Please either format your code or (better!) link to your submission - the forum software has mangled it and it won’t compile! :slight_smile:

Also - what Problem are you trying to solve? :slight_smile:

1 Like