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. Scrum立会报告+燃尽图(Final阶段第七次)

    此作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2486 项目地址:https://coding.net/u/wuyy694 ...

  2. C# 词频统计 东北师范大学 软件项目管理 第一次作业

    一.作为杨老师的学生第一次听杨老师讲课,印象最深的就是:工程中所有步骤之间是乘法,如果任何一步为0,工程就做不出来了.以前所有老师讲到的都是不要太在乎结果,努力的过程很重要,但是这在软件工程中不合适了 ...

  3. Redis学习笔记之单机实现

    1.数据库 Redis的所有数据库都保存在redisServer.db数组中,数据库主要是由两个字典组成:dict字典,负责保存键值对:expires,负责保存键的过期时间 Redis使用惰性删除和定 ...

  4. OpenState安装及 Port Knocking 实验

    OpenState安装及 Port Knocking 实验 目录 OpenState安装 Port Knocking 实验 OpenState安装及 Port Knocking 实验 OpenStat ...

  5. level3

    伸冤下:老师的评论是有看到!看完我就去修改程序了,忘记回复请原谅!= = 前阵子都在修改功能和思路,但是由于一个细节的错误找不到,导致没有成品可以上传...求谅解. 细心真的很重要 = =!!! im ...

  6. Navicat Premium和Navicat for MySQL哪个好用?

    之前在Navicat官网下载了Navicat Premium和Navicat for MySQL使用.Navicat官网产品下载地址:https://www.navicat.com.cn/produc ...

  7. flex与滚动冲突

    如果设置方向用了flex,那么用滚动就没用

  8. phaser3 微信小游戏入门

    phaser与eget, laya, pixi.js本质上没什么区别. 都是渲染引擎.  其它的都是配角.  phaser的特点是.代码容易理解 功能比较全面. 个人比较喜欢phaser的地方 twe ...

  9. 基于接口回调详解JUC中Callable和FutureTask实现原理

    Callable接口和FutureTask实现类,是JUC(Java Util Concurrent)包中很重要的两个技术实现,它们使获取多线程运行结果成为可能.它们底层的实现,就是基于接口回调技术. ...

  10. Spring之使用表达式配置切入点

    使用表达式配置切入点