Language: C++

#include <bits/stdc++.h>
using namespace std;
#define N 32
#define MOD 1e6+7
#define INF 0x3f3f3f3f
string s[N],str[N],col[N],col2[N];
int hash[N],hash2[N];
vector <string> Hash[MOD];
vector <string> Hash2[MOD];
map <string,bool> vis;
map <string,bool> vis2;
int main()
{
	//freopen("qc.in","r",stdin);
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		cin>>s[i];
		for(int j=0;j<m;j++)
		{
			hash[i]*=s[i][j];
			hash[i]%=MOD;
		}
		Hash[hash[i]].push_back(s[i]);
	}
	int cnt1=0,cnt2=0;
	for(int i=1;i<=n;i++)
	{
		if(Hash[hash[i]].size()%2==0)cnt2++;
		else cnt1++;
	}
	if(cnt1>=2)
	{
		puts("NO");
		return 0;
	}
	if(n%2==1)
	{
		for(int i=1;i<=n;i++)
		{
			if(Hash[hash[i]].size()%2==1)
			{
				str[n/2+1]=Hash[hash[i]][0];
				Hash[hash[i]].erase(Hash[hash[i]].begin());
				break;
			}
		}
	}
	int t=1;
	for(int i=1;i<=n;i++)
	{
		int len=Hash[hash[i]].size();
		for(int j=0;j<len;j++)
		{
			if(vis[Hash[hash[i]][j]])continue;
			vis[Hash[hash[i]][j]]=1;
			str[t]=Hash[hash[i]][j];
			str[n-t+1]=Hash[hash[i]][len-j-1];
			vis[Hash[hash[i]][len-j-1]]=1;
			t++;
		}
	}
	/*for(int i=1;i<=n;i++)
	{
		cout<<str[i]<<endl;
	}
	puts("");*/
	for(int j=1;j<=m;j++)
	{
		for(int i=1;i<=n;i++)
		{
			col[j]=col[j]+str[i][j-1];
		}
	}
	/*for(int j=1;j<=m;j++)
	{
		cout<<col[j]<<endl;
	}
	puts("");*/
	for(int j=1;j<=m;j++)
	{
		for(int i=0;i<n;i++)
		{
			hash2[j]*=col[j][i];
			hash2[j]%=MOD;
		}
		Hash2[hash2[j]].push_back(col[j]);
	}
	cnt1=0,cnt2=0;
	for(int i=1;i<=m;i++)
	{
		if(Hash2[hash2[i]].size()%2==0)cnt2++;
		else cnt1++;
	}
	if(cnt1>=2)
	{
		puts("NO");
		return 0;
	}
	if(m%2==1)
	{
		for(int i=1;i<=m;i++)
		{
			if(Hash2[hash2[i]].size()%2==1)
			{
				col2[n/2+1]=Hash2[hash2[i]][0];
				Hash2[hash2[i]].erase(Hash2[hash2[i]].begin());
				break;
			}
		}
	}
	t=1;
	for(int i=1;i<=m;i++)
	{
		int len=Hash2[hash2[i]].size();
		for(int j=0;j<len;j++)
		{
			if(vis2[Hash2[hash2[i]][j]])continue;
			vis2[Hash2[hash2[i]][j]]=1;
			col2[t]=Hash2[hash2[i]][j];
			col2[m-t+1]=Hash2[hash2[i]][len-j-1];
			vis2[Hash2[hash2[i]][len-j-1]]=1;
			t++;
		}
	}
	/*for(int i=1;i<=m;i++)
	{
		cout<<col2[i]<<endl;
	}*/
	/*for(int i=1;i<=m;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(col2[i][j]!=col2[m-i+1][n-j-1])
			{
				puts("NO");
				return 0;
			}
		}
	}*/
	puts("YES");
	return 0;
}

Compiler output:
a.cc:4:16: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    4 | #define MOD 1e6+7
      |             ~~~^~
a.cc:8:22: note: in expansion of macro 'MOD'
    8 | vector <string> Hash[MOD];
      |                      ^~~
a.cc:4:16: error: could not convert '(1.0e+6 + (double)7)' from 'double' to 'long unsigned int'
    4 | #define MOD 1e6+7
      |             ~~~^~
      |                |
      |                double
a.cc:8:22: note: in expansion of macro 'MOD'
    8 | vector <string> Hash[MOD];
      |                      ^~~
a.cc:4:16: error: size of array 'Hash' has non-integral type 'double'
    4 | #define MOD 1e6+7
      |             ~~~^~
a.cc:8:22: note: in expansion of macro 'MOD'
    8 | vector <string> Hash[MOD];
      |                      ^~~
a.cc:4:16: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    4 | #define MOD 1e6+7
      |             ~~~^~
a.cc:9:23: note: in expansion of macro 'MOD'
    9 | vector <string> Hash2[MOD];
      |                       ^~~
a.cc:4:16: error: could not convert '(1.0e+6 + (double)7)' from 'double' to 'long unsigned int'
    4 | #define MOD 1e6+7
      |             ~~~^~
      |                |
      |                double
a.cc:9:23: note: in expansion of macro 'MOD'
    9 | vector <string> Hash2[MOD];
      |                       ^~~
a.cc:4:16: error: size of array 'Hash2' has non-integral type 'double'
    4 | #define MOD 1e6+7
      |             ~~~^~
a.cc:9:23: note: in expansion of macro 'MOD'
    9 | vector <string> Hash2[MOD];
      |                       ^~~
a.cc: In function 'int main()':
a.cc:22:25: error: reference to 'hash' is ambiguous
   22 |                         hash[i]*=s[i][j];
      |                         ^~~~
In file included from /usr/include/c++/14/string_view:50,
                 from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:5: note:                 'int hash [32]'
    7 | int hash[N],hash2[N];
      |     ^~~~
a.cc:23:25: error: reference to 'hash' is ambiguous
   23 |                         hash[i]%=MOD;
      |                         ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:5: note:                 'int hash [32]'
    7 | int hash[N],hash2[N];
      |     ^~~~
a.cc:25:22: error: reference to 'hash' is ambiguous
   25 |                 Hash[hash[i]].push_back(s[i]);
      |                      ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:5: note:                 'int hash [32]'
    7 | int hash[N],hash2[N];
      |     ^~~~
a.cc:30:25: error: reference to 'hash' is ambiguous
   30 |                 if(Hash[hash[i]].size()%2==0)cnt2++;
      |                         ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:5: note:                 'int hash [32]'
    7 | int hash[N],hash2[N];
      |     ^~~~
a.cc:42:33: error: reference to 'hash' is ambiguous
   42 |                         if(Hash[hash[i]].size()%2==1)
      |                                 ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:5: note:                 'int hash [32]'
    7 | int hash[N],hash2[N];
      |     ^~~~
a.cc:44:49: error: reference to 'hash' is ambiguous
   44 |                                 str[n/2+1]=Hash[hash[i]][0];
      |                                                 ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:5: note:                 'int hash [32]'
    7 | int hash[N],hash2[N];
      |     ^~~~
a.cc:45:38: error: reference to 'hash' is ambiguous
   45 |                                 Hash[hash[i]].erase(Hash[hash[i]].begin());
      |                                      ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:5: note:                 'int hash [32]'
    7 | int hash[N],hash2[N];
      |     ^~~~
a.cc:45:58: error: reference to 'hash' is ambiguous
   45 |                                 Hash[hash[i]].erase(Hash[hash[i]].begin());
      |                                                          ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:5: note:                 'int hash [32]'
    7 | int hash[N],hash2[N];
      |     ^~~~
a.cc:53:30: error: reference to 'hash' is ambiguous
   53 |                 int len=Hash[hash[i]].size();
      |                              ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:5: note:                 'int hash [32]'
    7 | int hash[N],hash2[N];
      |     ^~~~
a.cc:56:37: error: reference to 'hash' is ambiguous
   56 |                         if(vis[Hash[hash[i]][j]])continue;
      |                                     ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:5: note:                 'int hash [32]'
    7 | int hash[N],hash2[N];
      |     ^~~~
a.cc:57:34: error: reference to 'hash' is ambiguous
   57 |                         vis[Hash[hash[i]][j]]=1;
      |                                  ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:5: note:                 'int hash [32]'
    7 | int hash[N],hash2[N];
      |     ^~~~
a.cc:58:37: error: reference to 'hash' is ambiguous
   58 |                         str[t]=Hash[hash[i]][j];
      |                                     ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:5: note:                 'int hash [32]'
    7 | int hash[N],hash2[N];
      |     ^~~~
a.cc:59:41: error: reference to 'hash' is ambiguous
   59 |                         str[n-t+1]=Hash[hash[i]][len-j-1];
      |                                         ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:5: note:                 'int hash [32]'
    7 | int hash[N],hash2[N];
      |     ^~~~
a.cc:60:34: error: reference to 'hash' is ambiguous
   60 |                         vis[Hash[hash[i]][len-j-1]]=1;
      |                                  ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:7:5: note:                 'int hash [32]'
    7 | int hash[N],hash2[N];
      |     ^~~~
a.cc:86:33: error: invalid operands of types 'int' and 'double' to binary 'operator%'
   86 |                         hash2[j]%=MOD;
      |                                 ^
a.cc:86:33: note:   in evaluation of 'operator%=(int, double)'