Loading [MathJax]/jax/output/CommonHTML/config.js
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >Codeforces Round #514 (Div. 2) B. Forgery(思维+暴力)

Codeforces Round #514 (Div. 2) B. Forgery(思维+暴力)

作者头像
Ch_Zaqdt
发布于 2019-01-10 08:55:27
发布于 2019-01-10 08:55:27
44200
代码可运行
举报
文章被收录于专栏:Zaqdt_ACMZaqdt_ACM
运行总次数:0
代码可运行

题目链接:http://codeforces.com/contest/1059/problem/B

       题意是有一个n*m大的图形,现在有一张空白的纸(全是'.'),还有一个3*3的印章(除了中间的是'.'以外都是'#'),问能不能用印章把空白的纸打成输入的图形。

        思路就是暴力,一个一个去添加就好了,直接看代码吧。


AC代码:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#include <bits/stdc++.h>
#define maxn 1005
using namespace std;
char a[maxn][maxn],b[maxn][maxn];
int n,m;

void Fun(int x,int y)
{
	if(a[x+1][y] == '#' && a[x+2][y] == '#' && a[x][y+1] == '#' && a[x][y+2] == '#' && a[x+1][y+2] == '#' && a[x+2][y+2] == '#' && a[x+2][y+1] == '#'){
		b[x][y] = '#';
		b[x+1][y] = '#';
		b[x+2][y] = '#';
		b[x][y+1] = '#';
		b[x][y+2] = '#';
		b[x+1][y+2] = '#';
		b[x+2][y+2] = '#';
		b[x+2][y+1] = '#';
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)scanf("%s",a[i]);
	memset(b,'.',sizeof(b));
	
	for(int i=0;i<n-2;i++){
		for(int j=0;j<m-2;j++){
			if(a[i][j] == '#'){
				Fun(i, j);
			}
		}
	}
	bool flag = false;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(a[i][j] != b[i][j]){
				flag = true;
				break;
			}
		}
	}
	if(flag == false){
		puts("YES");
	}
	else{
		puts("NO");
	}
	return 0;
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018年10月07日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
Codeforces Round #512 Div. 2 A,B,C Vasya and Golden Ticket
题目链接:http://codeforces.com/contest/1058/problem/A
Ch_Zaqdt
2019/01/11
5440
Codeforces Round #546 (Div. 2) C. Nastya Is Transposing Matrices(思维)
题目链接:https://codeforces.com/contest/1136/problem/C
Ch_Zaqdt
2019/03/19
4550
Codeforces Round #531 (Div. 3) B. Array K-Coloring(思维)
题目链接:http://codeforces.com/contest/1102/problem/B
Ch_Zaqdt
2019/01/11
5860
Codeforces Round #519 B. Lost Array(思维)(1043B)
题目链接:http://codeforces.com/contest/1043/problem/B
Ch_Zaqdt
2019/01/10
3940
Codeforces Round #543 (Div. 2, based on Technocup 2019 Final Round) B. Mike and Children(思维)
题目链接:https://codeforces.com/contest/1121/problem/B
Ch_Zaqdt
2019/03/15
3890
Codeforces Round #526 (Div. 2) B. Kvass and the Fair Nut(思维)
题目链接:http://codeforces.com/contest/1084/problem/B
Ch_Zaqdt
2019/01/10
4780
Codeforces Round #615 (Div. 3)B. Collecting Packages
There is a robot in a warehouse and nn packages he wants to collect. The warehouse can be represented as a coordinate grid. Initially, the robot stays at the point (0,0)(0,0). The ii-th package is at the point (xi,yi)(xi,yi). It is guaranteed that there are no two packages at the same point. It is also guaranteed that the point (0,0)(0,0) doesn't contain a package.
glm233
2020/09/28
6800
Codeforces Round #615 (Div. 3)B. Collecting Packages
Codeforces Round #536 (Div. 2) B. Lunar New Year and Food Ordering(思维)
题目链接:http://codeforces.com/contest/1106/problem/B
Ch_Zaqdt
2019/03/05
4830
Codeforces Round #525 (Div. 2) B. Ehab and subtraction(思维)
题目链接:http://codeforces.com/contest/1088/problem/B
Ch_Zaqdt
2019/01/10
4480
Codeforces Round #541 (Div. 2) B. Draw!(思维)
题目链接:https://codeforces.com/contest/1131/problem/B
Ch_Zaqdt
2019/03/06
3980
Codeforces Global Round 2 C. Ramesses and Corner Inversion(思维)
版权声明:欢迎转载,若转载,请标明出处,如有错误,请指点,也欢迎大佬们给出优化方法 https://blog.csdn.net/Charles_Zaqdt/article/details/89067262
Ch_Zaqdt
2019/04/18
3710
Codeforces Round #503 (by SIS, Div. 2) C. Elections(思维)
题目链接:https://codeforces.com/contest/1020/problem/C
Ch_Zaqdt
2019/03/04
3870
Codeforces Round #514 (Div. 2) A. Cashier(水题)
题目链接:http://codeforces.com/contest/1059/problem/A
Ch_Zaqdt
2019/01/10
3620
Codeforces Round #416 (Div. 2)(A,思维题,暴力,B,思维题,暴力)
A. Vladik and Courtesy time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output At regular competition Vladik and Valera won a and b candies respectively. Vladik offered 1 his candy to Valera. After that
Angel_Kitty
2018/04/09
8760
Codeforces Round #416 (Div. 2)(A,思维题,暴力,B,思维题,暴力)
Educational Codeforces Round 61 (Rated for Div. 2) C. Painting the Fence(思维+前缀和)
题目链接:http://codeforces.com/contest/1132/problem/C
Ch_Zaqdt
2019/03/15
4100
Codeforces Round #539 (Div. 2) B. Sasha and Magnetic Machines(思维)
题目链接:https://codeforces.com/contest/1113/problem/B
Ch_Zaqdt
2019/03/06
4120
Codeforces Round #336 (Div. 2)【A.思维,暴力,B.字符串,暴搜,前缀和,C.暴力,D,区间dp,E,字符串,数学】
A. Saitama Destroys Hotel time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in
Angel_Kitty
2018/04/09
9960
Codeforces Round #404 (Div. 2)(A.水,暴力,B,排序,贪心)
A. Anton and Polyhedrons time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetra
Angel_Kitty
2018/04/08
9390
Codeforces Round #404 (Div. 2)(A.水,暴力,B,排序,贪心)
Codeforces Round #558 (Div. 2) B. Cat Party(思维)
题目链接:https://codeforces.com/contest/1163/problem/B2
Ch_Zaqdt
2019/05/15
4160
Good Bye 2018 B. New Year and the Treasure Geolocation(思维)
题目链接:http://codeforces.com/contest/1091/problem/B
Ch_Zaqdt
2019/01/10
4760
推荐阅读
相关推荐
Codeforces Round #512 Div. 2 A,B,C Vasya and Golden Ticket
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验