题目大意:

给出一个n*m的图案,你有一个印章,印章可以印出3*3的图案(图案是#),但中心的那一个点印不出来,印出来就像这样
问是否可以用印章印出那样的图案(可以覆盖印,但如果要印,整个印章都需在团内,不能像印章在左上角印,只印了一部分在图案上)

题解:

根据给出的图案我们来印一个图案。开始图案都是‘.’,扫一遍给出的图案(枚举中心那个点),因为中心那个点是不会印上的,所以不用管它,只要中心点的周围一圈全都是'#',那么我们就可以印,就在我们的图案上,把这一圈都赋为‘#’。最后把我们画出的图和原图案比对,如果一致就是YES,否则就是NO

在此diss出题人的毛式英语,真真是说了些神马,题意描述的一点也不清,还一连发了3条解释,不好意思看了解释我也还没明白题意,还是在和队友的交互中逐渐明白了题意......

#include<cstring>
#include<bits/stdc++.h>
#define mod 1000000007
#define INF 1000000007
using namespace std;
typedef long long ll;
int dx[]= {-1,0,1};
int dy[]= {-1,0,1};
int n,m;
char a[1010][1010];
char t[1010][1010];
bool pd(int x,int y)
{for(int i=0; i<3; ++i)for(int j=0; j<3; ++j){if(i==1 && j==1)continue;if(x+dx[i]<1 ||x+dx[i]>n || y+dy[i]<1 || y+dy[i]>m||a[x+dx[i]][y+dy[j]]!='#')return 0;}return 1;
}
void tu(int x,int y)
{for(int i=0; i<3; ++i)for(int j=0; j<3; ++j){if(i==1 && j==1)continue;t[x+dx[i]][y+dy[j]]='#';}
}
bool d()
{for(int i=1; i<=n; ++i)for(int j=1; j<=m; ++j)if(t[i][j]!=a[i][j])return 0;return 1;
}
int main()
{//freopen("input.txt","r",stdin);cin>>n>>m;for(int i=1; i<=n; ++i)for(int j=1; j<=m; ++j)cin>>a[i][j];bool flag=1;for(int i=1; i<=n; ++i)for(int j=1; j<=m; ++j)t[i][j]='.';for(int i=1; i<=n; ++i)for(int j=1; j<=m; ++j)//(i,j)是中心点if(pd(i,j))tu(i,j);if(d()==0)//如果图案不一致flag=0;if(flag)puts("YES");else puts("NO");return 0;
}

CodeForces - 1059B Forgery (思维)相关推荐

  1. codeforces 有意思的思维题 1 ~ 15

    codeforces 思维题 1.给定数组,求满足i < j and ai * aj = i + j的数对数量 2.第 i 步向前跳 i 步或后退 1 步 3.给两个点,求正方形的另两个点 4. ...

  2. codeforces数学1600day4[贪心数学公式推导CodeForces - 1151D ,思维CodeForces - 1085C,数论同余+组合计数 CodeForces - 1056B]

    A - Stas and the Queue at the Buffet CodeForces - 1151D 题目大意:就是给你n个人在排队,每个人都有一个ai值和bi值,每个人的不满意度就是f(i ...

  3. CodeForces - 364A Matrix(思维+数学)

    题目链接:点击查看 题目大意:给出一个长度为 n 的,只由十进制数字组成的字符串 s,可以构造出一个大小为 n * n 的矩阵,构造方法如下:b[ i ][ j ] = s[ i ] * s[ j ] ...

  4. Task On The Board CodeForces - 1367D(思维)

    Polycarp wrote on the board a string s containing only lowercase Latin letters ('a'-'z'). This strin ...

  5. Orac and Game of Life CodeForces - 1350E(思维+BFS)

    Please notice the unusual memory limit of this problem. Orac likes games. Recently he came up with t ...

  6. Ehab and Path-etic MEXs CodeForces - 1325C(思维+贪心)

    You are given a tree consisting of n nodes. You want to write some labels on the tree's edges such t ...

  7. Mind Control CodeForces - 1291C(思维)

    You and your n−1n−1 friends have found an array of integers a1,a2,-,ana1,a2,-,an. You have decided t ...

  8. codeforces 1060a(思维水题)

    Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", ...

  9. CodeForces - 1102A(思维题)

    https://vjudge.net/problem/2135388/origin Describe You are given an integer sequence 1,2,-,n. You ha ...

最新文章

  1. 机器学习(MACHINE LEARNING)MATLAB中微分方程的求解
  2. linux底层硬件需求,Linux系统的硬件设备驱动的底层结构讲解
  3. Ubuntu系统 VI 编辑器初试
  4. Mybatis原理初探
  5. 【Hibernate】Hibernate实体关系映射——单边的一对一关系
  6. pythonnet下载_Python for .NET
  7. closewait一直不释放_机床为什么要释放应力?怎么释放应力才好?
  8. 500张思维导图记38000单词_思维导图记单词,环环相扣难遗忘——2020奇速英语夏令营第三天...
  9. ZJU期末考试记录(研究生)——数据挖掘
  10. digest 用户认证 response生成算法
  11. Spring 源码解析 -- SpringWeb过滤器Filter解析
  12. jenkins教程菜鸟_Jenkins插件编译
  13. python实现50行代码_利用 50行Python 代码构建一个在线文本生成器!
  14. 算法设计与分析期末复习大全(算法填充题+综合题)
  15. 圆形插件html,jQuery简单实用的圆形进度条插件
  16. 学生用计算机如何算角度,如何用windows计算器计算角度的正弦值?
  17. WebSphere概述
  18. 利用微信机器人 自动发送验证码
  19. android camera拍照录像切换功能
  20. 论文中出现的 cf. i.e. s.t. e.g. w.r.t. et al. etc等英文缩写是什么意思

热门文章

  1. 技术无罪,那快播呢?
  2. 会话描述协议---SDP协议【详解】
  3. Vega Prime 虚拟现实开发技术
  4. linux卸载owncloud,CentOS6.4下安装ownCloud
  5. VMware虚拟机分辨率
  6. windows 向注册表添加开机启动项
  7. 如何在树莓派上安装 Fedora 25
  8. 金融网络安全建设更难了?看一线从业者的“实战”经验分享丨2023 INSEC WORLD
  9. 【高并发、高性能、高可用】“三高” 系统设计经验
  10. Gogs这款开源项目助你秒建Git服务!