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 ...
随机推荐
- 为 github markdown 文件生成目录(toc)
业务需要 在编写 github 项目时,有时候会编写各种 README.md 等 markdown 文件,但是 github 默认是没有目录的. 于是就自己写了一个小工具. markdown-toc ...
- Struts vs spring mvc
1. 机制.spring mvc 的入口是servlet, 而struts是filter(这里要指出,filter和servlet是不同的.以前认为filter是servlet的一种特殊),这样就导致 ...
- leetcode152
class Solution { public: int maxProduct(vector<int>& nums) { if(nums.empty()) ; ) ]; ]; // ...
- 1.MySQL基础
1.创建一个数据库: create database db_test; 2.创建一个表: MySQL [mysql]> use db_test; Database changed MySQL [ ...
- PHP对接微信支付采坑
第一次做PHP商城项目对接微信支付接口,踩了N次坑,这也不对,那也不对,搞了很久,查了一些资料,终于实现了支付功能,小小总结一下,万一下次遇到就不用到处找资料了. 微信扫码支付 前期准备: 1.微信公 ...
- js中json的使用
- html背景图星际导航图练习
html <body> <div class="box1"> <div></div> ...
- spring cloud 笔记
1.在工程的启动类中,通过@EnableDiscoveryClient向服务中心注册:并且向程序的ioc注入一个bean: restTemplate;并通过@LoadBalanced注解表明这个res ...
- oslo_messaging与rabbitmq
oslo_messaing通过kombu与rabbitmq建立channel连接,向rabbitmq中发送数据 在oslo_messaging/_drivers/impl_rabbit.py中,初始化 ...
- [Solution] 973. K Closest Points to Origin
Difficulty: Easy Problem We have a list of points on the plane. Find the K closest points to the ori ...