Help me in solving HATTRICK problem

My issue

Explain correct solution for this problem

My code

#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int a[6];
        for(int i=0;i<6;i++){
            cin>>a[i];
        }
        int w;
        for(int i=0;i<6;i++){
            if(a[i]==w && a[i+1]==w && a[i+2]==w){
                cout<<"YES\n";
            }
            else cout<<"NO\n";
        }
        
       
    }
    
    
    
    
    
    
    
    return 0;
}

Problem Link: Hattrick Practice Coding Problem - CodeChef

@aadi_2005
plzz refer my c++ code for better understanding of the logic

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

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    char a[6];
	    int fnd=0;
	    for(int i=0;i<6;i++)
	    {
	        cin>>a[i];
	    }
	    for(int i=1;i<5;i++)
	    {
	        if(a[i]=='W'&&a[i-1]=='W'&&a[i+1]=='W')
	        {
	            fnd=1;
	        }
	    }
	    if(fnd)
	    cout<<"YES";
	    else
	    cout<<"NO";
	    cout<<endl;
	}

}