Customized Chess Board

  • + 0 comments

    ** C++ solution**

    #include <bits/stdc++.h>
    
    using namespace std;
    
    
    int main()
    
    {
    	int t;
    	cin>>t;
    	while(t>0)
    	{
    		int n,flag=0;
    		cin>>n;
    		int arr[n][n];
    
    		for(int i=0;i<n;i++)
    		{
    			for(int j=0;j<n;j++)
    				cin>>arr[i][j];
    		}
    
    		for(int i=0;i<n;i++)
    		{
    			for(int j=0;j<n-1;j++)
    			{
    				if(arr[i][j]==arr[i][j+1])
    					flag=1;
    			}
    		}
    		if(flag==0)
    			cout<<"Yes"<<endl;
    		else
    			cout<<"No"<<endl;
    		t--;
    
    
    	}
    }