#include #include #include #include #include using namespace std; struct d{ int a,b,c; bool operator<(d x){ if(a == x.a){ if(b == x.b){ return c < x.c; } return b < x.b; } return a < x.a; } bool operator==(d x){ return a==x.a && b==x.b && c==x.c; } bool operator>(d x){ return !((*this) < x || (*this) == x); } }; int main(){ int h,w;cin>>h>>w; vector> A(h,vector(w)); int c = 0; for(int i = 0; h > i; i++){ for(int j = 0; w > j; j++){ cin>>A[i][j]; if(A[i][j] == '#')c++; } } if(c%2 || c==0){ cout << "NO" << endl; return 0; } int C = 0; set> X[h*w]; vector ZZ; for(int i = 0; h > i; i++){ for(int j = 0; w > j; j++){ for(int k = i; h > k; k++){ for(int l = j; w > l; l++){ //cout << (i-k)*w+(j-l)+h*w << endl; int tmp = (i-k)*w+(j-l)+h*w; ZZ.push_back({tmp,(i-k),(j-l)}); if(i==k && j==l)continue; if(A[i][j] == '#' && A[k][l] == '#'){ //cout << i-k << " " << j-l << endl; X[(i-k)*w+(j-l)+h*w].insert({i,j}); X[(i-k)*w+(j-l)+h*w].insert({k,l}); } } } } } //sort(ZZ.begin(),ZZ.end()); //ZZ.erase(unique(ZZ.begin(),ZZ.end()),ZZ.end()); //for(int i = 0; ZZ.size() > i; i++){ // cout << ZZ[i].a << " " << ZZ[i].b << " " << ZZ[i].c << endl; //} for(int i = 0; h*w > i; i++){ if(X[i].size() == c){ cout << "YES" << endl; return 0; } } cout << "NO" << endl; }