#abc241c. C - Connect 6
C - Connect 6
Score : points
问题描述
存在一个包含 行横向和 列纵向的网格,其中每个方格被涂成白色或黑色。
网格的状态由 个字符串 表示。如果 的第 个字符是 #
,则从上到下第 行、从左到右第 列的方格被涂成黑色。如果字符是 .
, 则该方格被涂成白色。
高桥最多可以选择两个白色方格,并将其涂成黑色。
判断是否存在一种可能性,使得网格中包含连续对齐(纵向、横向或对角线方向)的 个或更多黑色方格。
这里,当网格完全包含一个具有 行和 列的子网格,且该子网格至少在一个对角线上所有方格都被涂成黑色时,我们称网格包含 个或更多连续对齐的黑色方格(对角线方向)。
以上为通义千问 qwen-max 翻译,仅供参考。
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
.
Sample Input 1
8
........
........
.#.##.#.
........
........
........
........
........
Sample Output 1
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.
Sample Input 2
6
######
######
######
######
######
######
Sample Output 2
Yes
While Takahashi cannot choose a square to paint black, the grid already satisfies the condition.
Sample Input 3
10
..........
#..##.....
..........
..........
....#.....
....#.....
.#...#..#.
..........
..........
..........
Sample Output 3
No
update @ 2024/3/10 10:23:13