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 ...
随机推荐
- Shell 基础 -- 总结几种括号、引号的用法
Shell 脚本中经常需要用到一些括号.引号表达式,功能各不相同,本文详细介绍一下. 1.双引号 " " 双引号常用于包含一组字符串,在双引号中,除了 "$". ...
- LeetCode-3.无重复字符的最长字串
给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度. 示例 1: 输入: "abcabcbb" 输出: 3 解释: 因为无重复字符的最长子串是 "abc&qu ...
- Notes of Daily Scrum Meeting(12.8)
今日团队任务总结: 团队成员 今日团队工作 陈少杰 使用例子对json数据进行解析 王迪 确定搜索功能的接口 金鑫 对布局文件进行协助修改 雷元勇 开始进行搜索功能的代码实现 高孟烨 按照学长的样本对 ...
- Spark 实践——基于 Spark Streaming 的实时日志分析系统
本文基于<Spark 最佳实践>第6章 Spark 流式计算. 我们知道网站用户访问流量是不间断的,基于网站的访问日志,即 Web log 分析是典型的流式实时计算应用场景.比如百度统计, ...
- [转帖] sparkdev 的 博客 systemd
从 init 系统说起 https://www.cnblogs.com/sparkdev/p/8448237.html systemd的内容 需要学习下. linux 操作系统的启动首先从 BIOS ...
- ITSS相关的名词解释
1.ITSM(IT Service Management)IT服务管理.从宏观的角度可以理解为一个领域或行业,人中观的角度可以理解为一种IT管理的方法论,从微观的角度可以理解为是一套协同动作的流程.从 ...
- 常用的Hql语句
// HQL: Hibernate Query Language.// 特点:// >> 1,与SQL相似,SQL中的语法基本上都可以直接使用.// >> 2,SQL查询的是表 ...
- Java之扫描目录,修改文件内容
扫描目录下文件,修改文件中指定内容 package org.utils.tools.fileoper; import java.io.*; import java.util.ArrayList; im ...
- MVC 锚点
MVC 锚点 linkText:生成的链接所显示的文字 actionName:对应控制器的方法 routeValues:向对应的action传递的参数 controlName:指定控制器的名称 htm ...
- 【BZOJ2067】SZN(二分,动态规划,贪心)
[BZOJ2067]SZN(二分,动态规划,贪心) 题面 权限题额 Description String-Toys joint-stock 公司需要你帮他们解决一个问题. 他们想制造一个没有环的连通图 ...