Codeforce 1182B Plus from Picture
题目链接:http://codeforces.com/problemset/problem/1182/B
题意:检查图中 * 形成的是否是唯一的十字。
思路:dfs找到十字的中心,反向消除十字,最后检查是否有余留的 * ,如果有则图案不正确输出NO。
AC代码:
#include<bits/stdc++.h>
using namespace std;
int n,m;
char mp[][];
int dx[] = {,,,-};
int dy[] = {-,,,};
bool check(int x,int y)
{
if(mp[x][y] != '*')return false;
if(mp[x + ][y] != '*')return false;
if(mp[x - ][y] != '*')return false;
if(mp[x][y + ] != '*')return false;
if(mp[x][y - ] != '*')return false;
return true;
}
void up(int x,int y)
{
while(mp[x][++y] == '*') mp[x][y] = '.';
}
void down(int x,int y)
{
while(mp[x][--y] == '*') mp[x][y] = '.';
}
void left(int x,int y)
{
while(mp[--x][y] == '*') mp[x][y] = '.';
}
void right(int x,int y)
{
while(mp[++x][y] == '*') mp[x][y] = '.';
}
int main()
{
cin >> n >> m;
bool flag = false;
for(int i = ;i < n;i++)
{
cin >> mp[i];
}
for(int i = ;i < n;i++)
{
for(int j = ;j < m;j++)
{
if(check(i,j))
{
mp[i][j] = '.';
up(i,j);
down(i,j);
left(i,j);
right(i,j);
flag = true;
break;
}
}
if(flag)break;
}
for(int i = ;i < n;i++)
{
for(int j = ;j < m;j++)
{
if(mp[i][j] == '*')
{
flag = false;
break;
}
}
}
if(flag) cout << "YES";
else cout << "NO";
return ;
}
/*
5 5
..*..
.....
..*..
*****
..*..
*/
Codeforce 1182B Plus from Picture的更多相关文章
- 基于Picture Library创建的图片文档库中的上传多个文件功能(upload multiple files)报错怎么解决?
复现过程 首先,我创建了一个基于Picture Library的图片文档库,名字是 Pic Lib 创建完毕后,我点击它的Upload 下拉菜单,点击Upload Picture按钮 在弹出的对话框中 ...
- MFC Picture控件加载图片
CStatic *pPic = (CStatic*)GetDlgItem(IDC_PICTURE); CBitmap bitmap; bitmap.LoadBitmapW(IDB_BITMAP2); ...
- [POJ1177]Picture
[POJ1177]Picture 试题描述 A number of rectangular posters, photographs and other pictures of the same sh ...
- Codeforce - Street Lamps
Bahosain is walking in a street of N blocks. Each block is either empty or has one lamp. If there is ...
- USACO 5.5 Picture(周长并)
POJ最近做过的原题. /* ID: cuizhe LANG: C++ TASK: picture */ #include <cstdio> #include <cstring> ...
- 彩色照片转换为黑白照片(Color image converted to black and white picture)
This blog will be talking about the color image converted to black and white picture. The project st ...
- HDU 1828 Picture(线段树扫描线求周长)
Picture Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Su ...
- don't forget the bigger picture
Imagine a circle that contains all of human knowledge: By the time you finish elementary school, you ...
- A Complete Guide to the <Picture> Element
If you’ve ever struggled building responsive websites, this post is for you. It’s part of a series o ...
随机推荐
- web开发小知识
session共享机制:f5刷新是再次提交之前的数据请求 地址栏回车属于不同的请求 不同浏览器获取不到之前数据 同一浏览器可以获取同步数据 session注销:session.invalidate() ...
- Linux下tomcat启动慢,阻塞
声明:本文为转载,请尊重版权,原文地址: https://www.cnblogs.com/songjinju/p/7505564.html 这两天在linux部署完tomcat以后,发现每次启动都非常 ...
- 运维 07 Linux系统基础优化及常用命令
Linux系统基础优化及常用命令 Linux基础系统优化 引言没有,只有一张图. Linux的网络功能相当强悍,一时之间我们无法了解所有的网络命令,在配置服务器基础环境时,先了解下网络参数设定命令 ...
- 20140914 1到N自然数排序
1.关于一道1到N自然数排序的华为面试题 http://blog.csdn.net/hongyuan19/article/details/1887656 为什么想进入华为 你对华为了解多少? 华为给我 ...
- 字母所对应的Unicode编码
A~Z 65~90 a~z 97~122 public class Unicode { public static void main(S ...
- Python - 元组 , range
元组和元组嵌套 元组: 俗称不可变的列表.又被成为只读列表, 元组也是python的基本数据类型之一, 用小括号括起来, 里面可以放任何数据类型的数据, 查询可以. 循环也可以. 切片也可以. 但就是 ...
- 树莓派上Opencv highgui的问题
错误描述:https://bbs.csdn.net/topics/394616975?page=1#post-409508178 解决方案:直接改系统环境变量 # vim /etc/profile e ...
- vue 中引入cryptoJS
在搞前端开发的时候,页面上有很多的地方是需要用户输入信息的,但是有些信息又很敏感,比如客户的姓名.电话号码.身份证号码.银行卡号及密码等等这些,如果没有进行加密处理,很容易被别人截取到,项目中应用到c ...
- 【牛客网-剑指offer】旋转数组的最小数字
题目: 把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转. 输入一个非递减排序的数组的一个旋转,输出旋转数组的最小元素. 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋 ...
- EntityFramework 知识点与sql优化汇总
一.EntityFramework modelBuilder.Entity<Domain.UseOilPlanDetail>().HasRequired(x => x.MainOil ...