閱讀812 返回首頁    go 阿裏雲 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)詳解