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 ...
随机推荐
- CentOS7.5 yum 安装与配置MySQL5.7.24
安装环境:CentOS7 64位 MINI版,安装MySQL5.7 1.配置YUM源 在MySQL官网中下载YUM源rpm安装包:https://dev.mysql.com/downloads/rep ...
- 【C++第一个Demo】---控制台RPG游戏4【角色系统】
[角色基类] #ifndef _ROLE_H_ #define _ROLE_H_ #include<list> #include<vector> #include " ...
- POJ 2001 Shortest Prefixes (Trie)
题目链接:POJ 2001 Description A prefix of a string is a substring starting at the beginning of the given ...
- 【Linux】- CentOS7安装java运行环境
centos7中安装java环境,在安装前先查看有无安装过java环境.直接运行java命令,会提示命令未找到,则是没有安装过java环境. 1.检查 也可以通过rpm命令查看: rpm -qa |g ...
- 高级UI晋升之自定义View实战(六)
更多Android高级架构进阶视频学习请点击:https://space.bilibili.com/474380680本篇文章将从Android 自定义属性动画&Camera动画来介绍自定义V ...
- Scala 槽点 - require
require def this(name: String, age: Int) = { this() require(name != null && !name.isEmpty, & ...
- 关于document.body.scrollTop用法
网页可见区域宽: document.body.clientWidth;网页可见区域高: document.body.clientHeight;网页可见区域宽: document.body.offset ...
- 20-python基础-python3-reversed()函数
描述 reversed 函数返回一个反转的迭代器. 语法 reversed(seq) 参数 seq -- 要转换的序列,可以是 tuple, string, list 或 range. # 字符串 s ...
- java selenium爬取验证图片是否加载完成
爬虫任务里发现有部分图片没有加载完成就进行文件流上传,导致有一些图片是空白,需要判断一下: 首选获取image标签元素: WebElement image = driver.findElement(B ...
- Hibernate4之注解零配置
@Entity ,注册在类头上,将一个类声明为一个实体bean(即一个持久化POJO类) . @Table ,注册在类头上,注解声明了该实体bean映射指定的表(table). @Id用来注册主属性, ...