阅读812 返回首页    go 技术社区[云栖]


模拟-codeforces-389B-Fox and Cross

Fox and Cross

Description

Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells.

 Each cell contains either a symbol '.', or a symbol '#'. A cross on the board is a connected set of exactly five cells of the board that looks like a cross. The picture below shows how it looks.

  #

###

  #

Ciel wants to draw several (may be zero) crosses on the board. Each cross must cover exactly five cells with symbols '#', and any cell with symbol '#' must belong to some cross. No two crosses can share a cell.

Please, tell Ciel if she can draw the crosses in the described way.

Input

The first line contains an integer n (3 ≤ n ≤ 100) — the size of the board.

Each of the next n lines describes one row of the board. The i-th line describes the i-th row of the board and consists of n characters. Each character is either a symbol '.', or a symbol '#'.

Output

Output a single line with "YES" if Ciel can draw the crosses in the described way. Otherwise output a single line with "NO".

Sample Input

5
.#...
####.
.####
...#.
.....

4
####
####
####
####

6
.#....
####..
.####.
.#.##.
######
.#..#.

6
.#..#.
######
.####.
.####.
######
.#..#.

3
...
...
...

Sample Output

YES

NO

YES

NO

YES

 微笑大意:一个 Cross要占据5个格子,要求:cross之间不能共用格子;cross只能占据形状为'#'的格子。

问你能不能画cross,把‘#’形状的格子用完。

解决:从上到下,从左至右,看当前格子能不能作为cross的五块之中的第一块。若可以,进一步检查。若仍可以,将五个格子从'#'置为'.'。看最后有没有剩余的'#'状格子。

 

 

 

最后更新:2017-04-03 12:56:33

  上一篇:go undone有关链表
  下一篇:go VMWare 网络连接模式(bridged、NAT、host-only)详解