I have tried using this c++ code to solve the problem. I tried individual cases and they worked, but it is not giving me the required output when I run it in the testcase while loop.
If someone could help it would be great.
#include<bits/stdc++.h>
using namespace std;
int main() {
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int a[1000][1000];
int symm=1;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cin>>a[i][j];
}
}
for(int i=0;i<n/2;i++)
{
for(int j=0;j<n/2;j++)
{
if(a[i][j]!=a[n-1-i][j] && a[i][j]!=a[i][n-1-j])
{
symm=0;
break;
}
}
if(symm==0) break;
}
if(symm)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
}