CF1150B.Tiling Challenge

传统题 时间 2000 ms 内存 256 MiB 4 尝试 1 已通过 1 标签

Tiling Challenge

One day Alice was cleaning up her basement when she noticed something very curious: an infinite set of wooden pieces! Each piece was made of five square tiles, with four tiles adjacent to the fifth center tile:

By the pieces lay a large square wooden board. The board is divided into n2n^2 cells arranged into nn rows and nn columns. Some of the cells are already occupied by single tiles stuck to it. The remaining cells are free.

Alice started wondering whether she could fill the board completely using the pieces she had found. Of course, each piece has to cover exactly five distinct cells of the board, no two pieces can overlap and every piece should fit in the board entirely, without some parts laying outside the board borders. The board however was too large for Alice to do the tiling by hand. Can you help determine if it's possible to fully tile the board?

Input

The first line of the input contains a single integer nn (3n503 \leq n \leq 50) — the size of the board.

The following nn lines describe the board. The ii-th line (1in1 \leq i \leq n) contains a single string of length nn. Its jj-th character (1jn1 \leq j \leq n) is equal to "." if the cell in the ii-th row and the jj-th column is free; it is equal to "#" if it's occupied.

You can assume that the board contains at least one free cell.

Output

Output YES if the board can be tiled by Alice's pieces, or NO otherwise. You can print each letter in any case (upper or lower).

Note

The following sketches show the example boards and their tilings if such tilings exist:

Samples

3
#.#
...
#.#
YES
4
##.#
#...
####
##.#
NO
5
#.###
....#
#....
###.#
#####
YES
5
#.###
....#
#....
....#
#..##
NO

在线编程 IDE

建议全屏模式获得最佳体验