My code is correct but the server says it is incorrect while my output is same as the expected outpu

My issue

My code

// Update your code below to solve the problem


#include <bits/stdc++.h>
using namespace std;

int main() 
{
	int t;
    cin >> t;
	
	int team_1 = 0;
	int team_2 = 0;
	
	while(t--)
	{
	    int A[10];
	    for(int i = 0; i < 10; i++)
	    {
	        cin >> A[i];
	    }
	    for (int i=0; i<10; i++ )
	    { 
	        if ((i%2 == 0) && A[i] != 0)
	        {
	            team_1 = team_1 + 1;
	        }
	        else if ((i%2 != 0) && A[i] != 0)
	        {
	            team_2 = team_2 +1;
	        }
	    }
	  if (team_2 > team_1)
	  {
	  cout << 2 << endl;
	  }
	  
	  else if (team_1 > team_2)
	{
	  cout << 1 << endl;
	}
	
	  else 
	{
	    cout << 0 << endl;
	}
	}	
    return 0;
}
 

Learning course: C++ for problem solving - 2
Problem Link: CodeChef: Practical coding for everyone

@shlok033
You have initialized score of both teams outside of test case loop, which is causing it to NOT reset to zero for every test case iteration and thus giving wrong answer.

Just place them inside while loop and it should work fine.