Codeforces Round 556 (Div. 2)
B
Tiling Challenge
Codeforces
900
原题
← AC →
翻译中…

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:

翻译中…

image

翻译中…

By the pieces lay a large square wooden board. The board is divided into $n^2$ cells arranged into $n$ rows and $n$ 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 $n$ ($3 \leq n \leq 50$) — the size of the board.

翻译中…

The following $n$ lines describe the board. The $i$-th line ($1 \leq i \leq n$) contains a single string of length $n$. Its $j$-th character ($1 \leq j \leq n$) is equal to "." if the cell in the $i$-th row and the $j$-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:

翻译中…

image

翻译中…

样例

Input #1
3
#.#
...
#.#
Output #1
YES
InputCopy OutputCopy
Input #2
4
##.#
#...
####
##.#
Output #2
NO
InputCopy OutputCopy
Input #3
5
#.###
....#
#....
###.#
#####
Output #3
YES
InputCopy OutputCopy
Input #4
5
#.###
....#
#....
....#
#..##
Output #4
NO
InputCopy OutputCopy
题目信息
题号
1150B
时间限制
2 s
内存限制
256 MB
标签
贪心
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。