A12498 | Tiling Challenge
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $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?
 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?
输入格式
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.
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 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).
输入输出样例
输入 #1
3 #.# ... #.#
输出 #1
YES
输入 #2
4 ##.# #... #### ##.#
输出 #2
NO
输入 #3
5 #.### ....# #.... ###.# #####
输出 #3
YES
输入 #4
5 #.### ....# #.... ....# #..##
输出 #4
NO
The following sketches show the example boards and their tilings if such tilings exist:


C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted