CodeForces - 1059B Forgery (思维)
题目大意:
给出一个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 (思维)相关推荐
- codeforces 有意思的思维题 1 ~ 15
codeforces 思维题 1.给定数组,求满足i < j and ai * aj = i + j的数对数量 2.第 i 步向前跳 i 步或后退 1 步 3.给两个点,求正方形的另两个点 4. ...
- codeforces数学1600day4[贪心数学公式推导CodeForces - 1151D ,思维CodeForces - 1085C,数论同余+组合计数 CodeForces - 1056B]
A - Stas and the Queue at the Buffet CodeForces - 1151D 题目大意:就是给你n个人在排队,每个人都有一个ai值和bi值,每个人的不满意度就是f(i ...
- CodeForces - 364A Matrix(思维+数学)
题目链接:点击查看 题目大意:给出一个长度为 n 的,只由十进制数字组成的字符串 s,可以构造出一个大小为 n * n 的矩阵,构造方法如下:b[ i ][ j ] = s[ i ] * s[ j ] ...
- Task On The Board CodeForces - 1367D(思维)
Polycarp wrote on the board a string s containing only lowercase Latin letters ('a'-'z'). This strin ...
- 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 ...
- 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 ...
- 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 ...
- codeforces 1060a(思维水题)
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", ...
- CodeForces - 1102A(思维题)
https://vjudge.net/problem/2135388/origin Describe You are given an integer sequence 1,2,-,n. You ha ...
最新文章
- 机器学习(MACHINE LEARNING)MATLAB中微分方程的求解
- linux底层硬件需求,Linux系统的硬件设备驱动的底层结构讲解
- Ubuntu系统 VI 编辑器初试
- Mybatis原理初探
- 【Hibernate】Hibernate实体关系映射——单边的一对一关系
- pythonnet下载_Python for .NET
- closewait一直不释放_机床为什么要释放应力?怎么释放应力才好?
- 500张思维导图记38000单词_思维导图记单词,环环相扣难遗忘——2020奇速英语夏令营第三天...
- ZJU期末考试记录(研究生)——数据挖掘
- digest 用户认证 response生成算法
- Spring 源码解析 -- SpringWeb过滤器Filter解析
- jenkins教程菜鸟_Jenkins插件编译
- python实现50行代码_利用 50行Python 代码构建一个在线文本生成器!
- 算法设计与分析期末复习大全(算法填充题+综合题)
- 圆形插件html,jQuery简单实用的圆形进度条插件
- 学生用计算机如何算角度,如何用windows计算器计算角度的正弦值?
- WebSphere概述
- 利用微信机器人 自动发送验证码
- android camera拍照录像切换功能
- 论文中出现的 cf. i.e. s.t. e.g. w.r.t. et al. etc等英文缩写是什么意思