CodeForces 1059B
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
3 3
###
#.#
###
YES
3 3
###
###
###
NO
4 3
###
###
###
###
YES
5 7
.......
.#####.
.#.#.#.
.#####.
.......
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):
- we have a clear paper:
...
...
...
... - use the pen with center at (2,2)(2,2).
###
#.#
###
... - 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的更多相关文章
- Forgery CodeForces - 1059B
一道印章刻印的题目: 具体要求:有一个固定的3*3的印章,给你一个墨迹问能用这个印章印出墨迹吗?(一个像素可以多次被上色) 输入:第一行是墨迹的行列规模,接下来是墨迹 输出:If Andrey can ...
- 2018SDIBT_国庆个人第六场
A - A codeforces 714A Description Today an outstanding event is going to happen in the forest — hedg ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
随机推荐
- it喜爱的歌词
1.曼丽 我们的过去我们的情义怎么能忘记 #曼丽你怎么这样忍心静静的就离去 #我很伤心从今以后不能够见到你 #只有留下你往日的情景使我常回忆 #一样的青山一样的绿水只有我和你 #曼丽可记得我们时常快 ...
- hadoop balance工具平衡集群dfs存储及遇到异常Got error, status message Not able to receive block 1073959989 from /192.168.1.37:3004 because threads quota is exceeded
hadoop集群某个节点dfs存储比其他节点存储高时,一般会使用hadoop提供的balance(start-balancer.sh -threshold 10 )工具来移动高存储节点上的块到低存储节 ...
- Linux内核分析作业二
贾瑗 + 原创作品转载请注明出处 + <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 一.操作系统是如 ...
- dispatch_block_t
通常我写一个不带参数的块回调函数是这样写的 在 . h 头文件中 定义类型 typedef void (^leftBlockAction)(); 在定义一个回调函数 -(void)leftButton ...
- SQL Server 删除重复数据只保留一条
DELETE FROM Bus_TerminalMessage_Keywords WHERE Content IN (select Content from Bus_TerminalMessage_K ...
- Alpha 冲刺四
团队成员 051601135 岳冠宇 051604103 陈思孝 031602629 刘意晗 031602248 郑智文 031602234 王淇 会议照片 项目燃尽图 项目进展 实现后端聊天接收,搜 ...
- 这两天学到的简单Linux的命令
1. 定时执行命令查看命令的接口 watch -n kubectl get pods -n kube-ops 每十秒钟查看一下命令运行接口 2. 后台方式运行 jenkins 当前窗口关闭不影响执行结 ...
- shit aliyun
shit aliyun 垃圾的 aliyun 什么鬼逻辑,怎么填写都不对,holy shit! 校验规则: // 对不起,昵称包含不可接受字符或被管理员屏蔽,请选择其它昵称 // 昵称的长度必须大于等 ...
- 查看iOS应用crash日志
基本操作: 1.电脑安装好Xcode,连接好手机设备 2.打开Xcode,点击Window-Devices and Simulators 3.选中手机设备,点击View Device Logs,即可查 ...
- c++ std::function
std::function 是一个模板类,用于封装各种类似于函数这样的对象,例如普通函数,仿函数,匿名函数等等.其强大的多态能力,让其使用只依赖于调用特征.在程序的升级中,可以实现一个调用表,以兼容新 ...