Codeforces Round #514 (Div. 2) B - Forgery
这个题我一开始没思路,最后也没思路
2个小时一直没思路
本来还想解释题意的,写了半天发现解释的不是很清楚,你还是google翻译一下吧
这个题解法是这样的:
首先,给你图案里面有很多的点,每个点的周围8个点都不可能在上面落笔,因为你一旦在周围8个点落笔,必定会覆盖掉这个点,
其次,每一个有#的地方,他周围8个点一定有一个地方能够落笔
所以我们把所有不可能落笔的点都记录下来,再判断每一个#的地方,假设周围有能落笔的地方,说明可以画
只要找到一个#周围没有可以落笔的地方,输出no
( 笔不能超过纸张,也就是说落笔范围在(1,1)(n-2,m-2)这个矩形里面)
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e3+;
char arr[maxn][maxn];
bool vis[maxn][maxn];
int n,m;
void painw(int x,int y)
{
vis[x+][y] = vis[x+][y-] = vis[x+][y+] = vis[x-][y] = vis[x-][y-] = vis[x-][y+] = false;
vis[x][y+] = vis[x][y-] = false;
}
bool pan(int x,int y)
{
bool f = false;
for(int i = -;i <= ;++i)
{
for(int j = -; j <= ; ++j)
{
//cout << x+i << " " << y+j << endl;
if(x+i <= || x+i >= n || y+j <= || y+j >= m)
continue;
if(i == && j == )
continue;
if(vis[x+i][y+j] == true)
f = true;
}
}
//cout << f << endl;
return f;
}
int main()
{
scanf("%d%d",&n,&m);
int cnt = ;
memset(vis,true,sizeof(vis));
for(int i = ; i <= n; ++i)
{
getchar();
for(int j = ; j <= m; ++j)
{
scanf("%c",arr[i]+j);
if(arr[i][j] == '.')
painw(i,j);
}
}
for(int i = ; i <= m+; ++i)
vis[][i] = vis[n+][i] = false;
for(int i = ; i <= n+; ++i)
vis[i][] = vis[i][m+] = false; /*for(int i = 0; i <=n+1; ++i)
{
for(int j = 0; j <= m+1; ++j)
printf("%d",vis[i][j]);
printf("\n");
}*/ for(int i = ; i <= n; ++i)
{
for(int j = ; j <= m; ++j)
{
if(arr[i][j] == '#' && pan(i,j) == false)
{
printf("NO\n");
return ;
}
}
}
printf("YES\n");
return ;
}
Codeforces Round #514 (Div. 2) B - Forgery的更多相关文章
- Codeforces Round #514 (Div. 2)
目录 Codeforces 1059 A.Cashier B.Forgery C.Sequence Transformation D.Nature Reserve(二分) E.Split the Tr ...
- Codeforces Round #514 (Div. 2) D. Nature Reserve
http://codeforces.com/contest/1059/problem/D 最大值: 最左下方和最右下方分别有一个点 r^2 - (r-1)^2 = (10^7)^2 maxr<0 ...
- Codeforces Round #514 (Div. 2) E. Split the Tree(倍增+贪心)
https://codeforces.com/contest/1059/problem/E 题意 给出一棵树,每个点都有一个权值,要求你找出最少条链,保证每个点都属于一条链,而且每条链不超过L个点 和 ...
- Codeforces Round #514 (Div. 2):D. Nature Reserve(二分+数学)
D. Nature Reserve 题目链接:https://codeforces.com/contest/1059/problem/D 题意: 在二维坐标平面上给出n个数的点,现在要求一个圆,能够容 ...
- Codeforces Round #514 (Div. 2) C. Sequence Transformation(递归)
C. Sequence Transformation 题目链接:https://codeforces.com/contest/1059/problem/C 题意: 现在有1~n共n个数,然后执行下面操 ...
- Codeforces Round #514 (Div. 2) C. Sequence Transformation 思维构造
题意 给出一个1-n的集合 gcd 集合里面的所有数 得到的 一个 数 然后自己选择删去一个数 要使得到的数 构成的数列 的字典序最大 思路: gcd所有数 那gcd得到的数肯定要小于数 ...
- Codeforces Round #514 (Div. 2) C. Sequence Transformation
题目大意:给你一个n 从1,2,3......n这个序列中 依次进行以下操作:1 .求所有数的最大公因数,放入a序列里面 2 .任意删去一个元素 一直到序列为空 根据删除元素的不同,导致序列a的字典序 ...
- Codeforces Round#514 Div.2 翻车记
A:签到 #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> # ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
随机推荐
- Spring AOP的底层实现原理
Spring的两大核心之一就是AOP,AOP:面向切面编程.在说原理之前,得先知道一些 AOP的专业术语. AOP的专业术语 连接点(JoinPoint):增强执行的位置(增加代码的位置),Sprin ...
- 《深入浅出 Java Concurrency》目录
最近在学习J.U.C,看到一个大神 关于这个系列写的非常精辟,由于想做笔记,故系列转载并记录之. 原文:http://www.blogjava.net/xylz/archive/2010/07/08/ ...
- android 开发 View _2_ View的属性动画ObjectAnimator ,动画效果一览
支持:https://www.cnblogs.com/whoislcj/p/5738478.html translationX的效果: protected void onCreate(Bundle s ...
- c#随机生成英文名
private static string GenerateSurname() { string name = string.Empty; string[] currentConson ...
- typedef typename
所以根据上述两条分析, typedef typename RefBase::weakref_type weakref_type; 语句的真是面目是: typedef创建了存在类型的别名,而typen ...
- js程序的调试方法
- Sqlite安装教程
Sqlite下载页面:http://www.sqlite.org/download.html Windows安装 需要下载 sqlite-tools-win32-*.zip 和 sqlite-dll- ...
- 在java项目中使用umeditor
之前有介绍了ueditor的用法,可看这篇:https://www.cnblogs.com/roy-blog/p/7250668.html umeditor是ueditor的简化版,不仅在功能,容量上 ...
- 738. Monotone Increasing Digits 单调递增的最接近数字
[抄题]: Given a non-negative integer N, find the largest number that is less than or equal to N with m ...
- git回滚远程仓库
关于远程仓库回滚 首先,必须要明白的一件事,任何普通用户不能擅自做有关远程仓库回退的操作,如果你擅自回滚了远程仓库,会对项目团队其他人造成不可预知的影响.如果需要回退版本,先联系项目的仓库管理员,在团 ...