9712648 | CodeChef

Please help me with this code. Why is it giving WA?

#include<bits/stdc++.h>
using namespace std;
int main()
{
	long t;
	cin>>t;
	for(long i=0;i<t;i++)
	{
		long n;
		cin>>n;
		string s;
		cin>>s;
		long count1=0,count2=0;long temp=2*n-2;
		for(long j=0;j<2*n;j+=2)
		{
			if(s[j]=='1')
			count1++;
			if(s[j+1]=='1')
			count2++;
			
			long rem=(n-(j/2+1));
			if(count1>count2+rem)
			{
				temp=j;
				break;
			}
			else if(count2>count1+rem)
			{
				temp=j;
				break;
			}
			
		}
		cout<<temp+2<<endl;
	}
	return 0;
}

You are checking when both team have played. There may be case when result was final when only first team played. You may see this CodeChef: Practical coding for everyone