#include #include #include int h, w; void print_array(int h, int w, int array[]) { for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { printf("%d", array[i * w + j]); if (j != w - 1) { printf(" "); } } printf("\n"); } } int check_board(int size, int array[]) { for (int i = 0; i < size; i++) { if (array[i] != 0) { return 0; } } return 1; } int main(int, char **) { scanf("%d %d", &h, &w); int board[h * w]; char s[w]; for (int i = 0; i < h; i++) { scanf("%s", s); for (int j = 0; j < w; j++) { if (s[j] == '#') { board[i * w + j] = 1; } else { board[i * w + j] = 0; } } } // print_array(h, w, board); // printf("\n"); if (check_board(h * w, board) == 1) { printf("NO\n"); return 0; } for (int y = -h; y < h; y++){ for (int x = -w; x < w; x++){ int board_new[h * w]; memcpy(board_new, board, sizeof(int) * h * w); for (int i = 0; i < h; i++){ for (int j = 0; j < w; j++){ if ((i + y < h) && (j + x < w) && (i + y >= 0) && (j + x >= 0)) { if ((board_new[i * w + j] == 1) && (board_new[(i + y) * w + (j + x)])) { board_new[i * w + j] = 0; board_new[(i + y) * w + (j + x)] = 0; } } } } // print_array(h, w, board_new); // printf("\n"); if (check_board(h*w, board_new) == 1 && !(y == 0 && x == 0)) { printf("YES\n"); return 0; } } } printf("NO\n"); return 0; }