atcoder#ABC241C. [ABC241C] Connect 6
[ABC241C] Connect 6
Score : points
Problem Statement
There is a grid with horizontal rows and vertical columns, where each square is painted white or black.
The state of the grid is represented by strings, .
If the -th character of is #
, the square at the -th row from the top and the -th column from the left is painted black.
If the character is .
, then the square is painted white.
Takahashi can choose at most two of these squares that are painted white, and paint them black. Determine if it is possible to make the grid contain or more consecutive squares painted black aligned either vertically, horizontally, or diagonally. Here, the grid is said to be containing or more consecutive squares painted black aligned diagonally if the grid with rows and columns completely contains a subgrid with rows and columns such that all the squares on at least one of its diagonals are painted black.
Constraints
- consists of
#
and.
.
Input
Input is given from Standard Input in the following format:
Output
If it is possible to fulfill the condition by painting at most two squares, then print Yes
; otherwise, print No
.
8
........
........
.#.##.#.
........
........
........
........
........
Yes
By painting the -rd and the -th squares from the left in the -rd row from the top, there will be squares painted black aligned horizontally.
6
######
######
######
######
######
######
Yes
While Takahashi cannot choose a square to paint black, the grid already satisfies the condition.
10
..........
#..##.....
..........
..........
....#.....
....#.....
.#...#..#.
..........
..........
..........
No