305587: CF1059B. Forgery
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Forgery
题意翻译
给定一个$n,m$的目标矩阵。 **初始矩阵全为$'.'$** 你可以染色无数次,每次选定一个格子将它周围的八个格子(除它自己)的3*3矩阵覆盖成'#'。 这个3*3的矩阵只能出现在$n*m$的矩阵内部。不能越界。 询问是否能构成目标矩阵。题目描述
Student Andrey has been skipping physical education lessons for the whole term, and now he must somehow get a passing grade on this subject. Obviously, it is impossible to do this by legal means, but Andrey doesn't give up. Having obtained an empty certificate from a local hospital, he is going to use his knowledge of local doctor's handwriting to make a counterfeit certificate of illness. However, after writing most of the certificate, Andrey suddenly discovered that doctor's signature is impossible to forge. Or is it? For simplicity, the signature is represented as an $ n\times m $ grid, where every cell is either filled with ink or empty. Andrey's pen can fill a $ 3\times3 $ square without its central cell if it is completely contained inside the grid, as shown below. `<br></br>xxx<br></br>x.x<br></br>xxx<br></br>`Determine whether is it possible to forge the signature on an empty $ n\times m $ grid.输入输出格式
输入格式
The first line of input contains two integers $ n $ and $ m $ ( $ 3 \le n, m \le 1000 $ ). Then $ n $ lines follow, each contains $ m $ characters. Each of the characters is either '.', representing an empty cell, or '\#', representing an ink filled cell.
输出格式
If Andrey can forge the signature, output "YES". Otherwise output "NO". You can print each letter in any case (upper or lower).
输入输出样例
输入样例 #1
3 3
###
#.#
###
输出样例 #1
YES
输入样例 #2
3 3
###
###
###
输出样例 #2
NO
输入样例 #3
4 3
###
###
###
###
输出样例 #3
YES
输入样例 #4
5 7
.......
.#####.
.#.#.#.
.#####.
.......
输出样例 #4
YES