#include <stdio.h> #include <iostream> #include <string.h> 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"); for (int y = 0; y < h - 1; y++){ for (int x = 0; x < w - 1; 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)) { 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; }