Codes manual input outputs are matchnig the testcases but it is getting "wrong " as responce. Please help.

#include
using namespace std;
int main()
{ int T,r=0,r1;;
cin>>T;
int result[T];
while(T>0){
int n,k,temp=0;
r1=r;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
if((a[i]%2==0) && (temp!=k))
{
temp=temp+1;
if(temp==k)
{

	     		result[r]=1;   
				 r=r+1; 				 
				 break;		
	     	
	     		}
	     	}
	     	else if(temp==k)
	     	{
	     		result[r]=1;   
				 r=r+1; 	     				
				 break;		
	     	}
	     	else
	     	{
	     		temp=0;
	     	}
	     	
	     }
	if((r1+1)!=r) 
	{
		result[r]=0;
		r++;
		
	}
	T=T-1;
}


for(int j=0;j<r;j++)
{
	if(result[j]==1)
	{
		cout<<"YES"<<"\n";
		
	}
	else
	{
		cout<<"NO"<<"\n";
	}

}

return 0;

}

//