#include #include #include #include #include #include #include using namespace std; int main() { int H, W; cin >> H >> W; int table[51][51]; int cnt = 0; for(int i = 0 ; i < H ; ++i) { string s; cin >> s; for(int j = 0 ; j < W ; ++j) { table[j][i] = s.at(j) == '#' ? 1 : 0; if(table[j][i]) ++cnt; } } if((cnt%2) != 0 || cnt ==0) { cout << "NO"; return 0; } for(int i = -W ; i < W ; ++i)for(int j = -H ; j < H ; ++j) { if(i==0 && j == 0) continue; int m[51][51]; for(int k = 0 ; k < W ; ++k)for(int l = 0 ; l < H ; ++l) { m[k][l] = table[k][l]; } int x, y; for(x = 0 ; x < W ; ++x)for(y = 0 ; y < H ; ++y) { if(m[x][y] != 1) continue; if(x+i < W && y+j < H && x+i >= 0 && y+j >= 0 && m[x+i][y+j] == 1) { m[x][y] = 2;//red m[x+i][y+j] = 3;//blue continue; } break; } if(x == W && y == H) { cout << "YES"; return 0; } } cout << "NO"; return 0; }