CF1150B.Tiling Challenge
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 n2 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?
一天,爱丽丝正在打扫她的地下室,突然注意到一件非常奇特的东西:一套无限多的木制拼块!每块拼块由五个正方形瓷砖组成,其中四个瓷砖均与中央的第五个瓷砖相邻:

在这些拼块旁边,放着一块大型正方形木板。该木板被划分为 n2 个单元格,排列成 n 行和 n 列。其中一些单元格已被单个固定在其上的瓷砖占据,其余单元格为空。
爱丽丝开始思考:她能否用手中找到的这些拼块将整块木板完全铺满?当然,每块拼块必须恰好覆盖木板上五个互不相同的单元格,任意两块拼块不得重叠,且每块拼块必须完全置于木板之内(不能有任何部分超出木板边界)。然而,这块木板对爱丽丝而言实在太大,无法手工完成铺砌。你能帮她判断是否可能将木板完全铺满吗?
输入格式
The first line of the input contains a single integer n (3≤n≤50) — the size of the board.
The following n lines describe the board. The i-th line (1≤i≤n) contains a single string of length n. Its j-th character (1≤j≤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.
输入的第一行包含一个整数 n(3≤n≤50)—— 表示棋盘的大小。
接下来的 n 行描述棋盘。第 i 行(1≤i≤n)包含一个长度为 n 的字符串。该字符串的第 j 个字符(1≤j≤n)为 ".",表示第 i 行第 j 列的格子为空;为 "#",表示该格子被占据。
你可以假设棋盘中至少存在一个空格子。
输出格式
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).
如果棋盘可以被爱丽丝的方块铺满,则输出 YES,否则输出 NO。每个字母可使用大写或小写形式。
输入输出样例
输入#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:

以下示意图展示了示例棋盘及其对应的铺砌方式(如果存在这样的铺砌):

输入解题思路,AI测评打分。不知道怎么写?