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 ...
随机推荐
- Eclipes 配置src.zip(查看源代码)
接着将这些改变应用,重启eclipes即可.
- export的用法
定义环境变量并且赋值 # export MYENV= //定义环境变量并赋值 # export -p declare -x HOME=“/root“ declare -x LANG=“zh_CN.UT ...
- proc伪文件系统 - 加载一个进程
内核模块的编译方法及注意事项 Ubuntu内核(2.6.32) 2.6内核中,模块的编译需要配置过的内核源码:编译.链接后生成的内核模块后缀为.ko:编译过程首先会到内核源码目录下读取顶层的Makef ...
- ios兼容问题
滑动卡顿: -webkit-overflow-scrolling:touch;
- LLppdd's class meeting!
LLppdd's class meeting! Time Limit: 1 s Memory Limit: 256 MB 题目背景 LLppdd 有一个可爱团结的班级,他们会定期举行班会活动...比如 ...
- cenos7 下数据库相关操作
1.Linux Centos7下如何确认MySQL服务已经启动 https://www.cnblogs.com/qianzf/p/7082484.html 2.CentOS 7上安装MySQL并配置远 ...
- xfce4之whisker不显示自定义启动器的解决
对某些启动比较麻烦的程序,想创建个启动器显示在whisker里,这样就能快速启动了. 通常自己创建的desktop文件可以放~/.local/share/applications里,但是按下面这个创建 ...
- Arch安装墨刀(产品原型工具)
Arch通过aur安装墨刀的时候报错,查看PKGBUILD发现下载地址错误("https://s3.cn-north-1.amazonaws.com.cn/modao/download&qu ...
- 【JDK1.8】Java HashMap实现细节
底层是用数组实现的 /** * The table, initialized on first use, and resized as * necessary. When allocated, len ...
- 关于Ring3层的注册表监控
最近一直想做远程操作的注册表,将客户端的注册表发送到主控端,遇到两个问题: 1.不能每次点击TreeControl都是一次请求的发送,太浪费资源. 2.在客户端的注册表监控效果也不是很好.(驱动不稳定 ...