#include #include int main() { enum class State{ None,Red,Blue,Undefined }; int height, width; std::cin >> height >> width; std::string l; std::getline(std::cin, l); State map[50][50]; int cell_count = 0; for (int y = 0; y < height; y++) { std::string line; std::getline(std::cin, line); for (int x = 0; x < width; x++) { if (line[x] == '.') { map[x][y] = State::None; } else { cell_count++; map[x][y] = State::Undefined; } } } bool is_find=false; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { if (x != 0 || y != 0) { is_find=true; int blue_count = 0; State map_copy[50][50]; for (int y1 = 0; y1 < height; y1++) { for (int x1 = 0; x1 < width; x1++) { map_copy[x1][y1] = map[x1][y1]; } } for (int y_add = 0; y_add < height; y_add++) { for (int x_add = 0; x_add < width; x_add++) { if (map_copy[x_add][y_add] == State::None) { }else if (x_add - x < 0 || y_add - y < 0) { blue_count++; map_copy[x_add][y_add] = State::Blue; if (blue_count * 2 > cell_count) { is_find = false; break; } } else if (map_copy[x_add - x][y_add - y] == State::Blue) { map_copy[x_add][y_add] = State::Red; } else { blue_count++; map_copy[x_add][y_add] = State::Blue; } } } loop2_end: if (is_find == true&& blue_count * 2 == cell_count) { goto loop1_end; } } } } loop1_end: std::cout << (is_find ? "YES" : "NO") << std::endl; }