Description

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×mn×m grid, where every cell is either filled with ink or empty. Andrey's pen can fill a 3×33×3 square without its central cell if it is completely contained inside the grid, as shown below.

xxx
x.x
xxx

Determine whether is it possible to forge the signature on an empty n×mn×m grid.

Input

The first line of input contains two integers nn and mm (3≤n,m≤10003≤n,m≤1000).

Then nn lines follow, each contains mm characters. Each of the characters is either '.', representing an empty cell, or '#', representing an ink filled cell.

Output

If Andrey can forge the signature, output "YES". Otherwise output "NO".

You can print each letter in any case (upper or lower).

Sample Input

Input
3 3
###
#.#
###
Output
YES
Input
3 3
###
###
###
Output
NO
Input
4 3
###
###
###
###
Output
YES
Input
5 7
.......
.#####.
.#.#.#.
.#####.
.......
Output
YES

Hint

In the first sample Andrey can paint the border of the square with the center in (2,2)(2,2).

In the second sample the signature is impossible to forge.

In the third sample Andrey can paint the borders of the squares with the centers in (2,2)(2,2) and (3,2)(3,2):

  1. we have a clear paper:

    ...
    ...
    ...
    ...
  2. use the pen with center at (2,2)(2,2).
    ###
    #.#
    ###
    ...
  3. use the pen with center at (3,2)(3,2).
    ###
    ###
    ###
    ###

In the fourth sample Andrey can paint the borders of the squares with the centers in (3,3)(3,3) and (3,5)(3,5).

不知为何,最近总是看错题意,并且非常自信的认为题意就是那样的?

这个问题需要注意一下了,最近这两场比赛全面崩盘都与看错题意有关,是自己太急躁了吗?

题中说了,每一笔都需要是一个完成的3*3的矩阵,且样例2也说明了这一点,但我愣是没看出来,导致一直WA。

很简单,暴力就完事了。

 #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<deque>
#include<iostream>
using namespace std;
typedef long long LL; char con[][];
char note[][];
int way[]= {,,-,,,,,-,,,-,,-,-,,-}; int main()
{
int i,p,j,n,m;
int flag=;
scanf("%d%d",&n,&m);
for(i=; i<=n; i++)
{
for(j=; j<=m; j++)
{
scanf(" %c",&con[i][j]);
if(con[i][j]=='.')
{
flag++;
}
}
} while()
{ // if(n==3&&m==3&&flag==0)
// {
// printf("NO\n");
// break;
// }
for(i=; i<n; i++)
{
for(j=; j<m; j++)
{
for(p=; p<=; p+=)
{
int x=i+way[p];
int y=j+way[p+];
if(con[x][y]=='.'&&x>=&&x<=n&&y>=&&y<=m)
break;
}
if(p>)
{
for(p=; p<=; p+=)
{
int x=i+way[p];
int y=j+way[p+];
if(x>=&&x<=n&&y>=&&y<=m)
{
note[x][y]='#';
}
}
}
}
}
int check=; for(i=; i<=n; i++)
{
for(j=; j<=m; j++)
{
if(con[i][j]!='.'&&con[i][j]!=note[i][j])
{
check=;
break;
}
}
if(check==)
break;
}
if(check==)
printf("NO\n");
else
printf("YES\n");
break;
}
return ;
}

CodeForces 1059B的更多相关文章

  1. Forgery CodeForces - 1059B

    一道印章刻印的题目: 具体要求:有一个固定的3*3的印章,给你一个墨迹问能用这个印章印出墨迹吗?(一个像素可以多次被上色) 输入:第一行是墨迹的行列规模,接下来是墨迹 输出:If Andrey can ...

  2. 2018SDIBT_国庆个人第六场

    A - A codeforces 714A Description Today an outstanding event is going to happen in the forest — hedg ...

  3. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  4. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  5. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  6. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  7. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  8. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  9. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

随机推荐

  1. 第一Sprint阶段对各组提出的意见

    组号  组名 意见 1 理财猫 1.界面深色的部分,字体应调成亮色,可以适当美化字体. 2.希望能够自动记录花销,而不是只能手动“记一笔”. 3.功能略少,比如可以添加“收入详情”.“支出详情”. 2 ...

  2. OpenState: Programming Platform-independent Stateful OpenFlow Applications Inside the Switch

    文章名称:OpenState: Programming Platform-independent Stateful OpenFlow Applications Inside the Switch Op ...

  3. 完善好的web项目(校园包车)

  4. Daily Scrum - 12/03

    Meeting Minutes   后端基本完成,结束当前Sprint, 开始下一个Sprint.进一步讨论了UI,并完成了任务分配.   Burndown     Progress   part 组 ...

  5. 老李的blog使用日记(3)

    匆匆忙忙.碌碌无为,这是下一个作业,VS,多么神圣高大上,即使这样,有多少人喜欢你就有多少人烦你,依然逃不了被推销的命运,这抑或是它喜欢接受的,但是作为被迫接受者,能做的的也只有接受,而已. 既来之则 ...

  6. JS基础(一)异常错误

    EvalError(运算错误): raised when an error occurs executing code in eval() RangeError(范围错误): raised when ...

  7. 如何判断可见字符 Unicode

    一个Unicode字符串,如何判断其中都是可见字符? //根据国标 GB2312 的中文汉字及符号 区位码的范围判断 Function CheckIsGB2312(Char : WideChar) : ...

  8. Docker(五)-Dcoker容器

    简单的说,容器是独立运行的一个或一组应用,以及它们的运行态环境. 如果把镜像看成面向对象中的 类 的话,那么容器就是 类 的实例化 对象. 容器 启动容器 启动容器有两种方式,一种是基于镜像新建一个容 ...

  9. C# DataTable Select用法

    DataRow[] dr = ds.Tables[0].Select("列名='该列你要查询的值'"); DataRow[] dr = ds.Tables[0].Select(&q ...

  10. NOI&&NOIP知识点集萃

    更新日志 \(update:2019-3-4\) 更新了自为风月马前卒的后缀数组(省选不到一个月了,我才开始学后缀数组怕是要凉凉) \(update:2019-2-21\) 更新了一篇李超线段树的讲解 ...