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 ...
随机推荐
- java入门经验分享——记面向对象先导课程学习感想
选择在暑期学习面向对象先导课程的初衷是为大二下学期面向对象课程做一些铺垫,接触入门java语言.在接触java的过程中,就编程语言的学习方法而言,我从刚入学时的手慌脚乱四处寻求帮助到现在慢慢养成了自己 ...
- 高水线 High water mark(HWM)
所有的Oracle表都有一个容纳数据的上限(很像一个水库历史最高的水位),我们把这个上限称为“High water mark"或HWM.这个HWM是一个标记(专门有一个数据块来记录高水标记等 ...
- SourceInsight 支持 Python
SourceInsight 支持 Python 步骤一:下载相关的插件 Python.CLF插件 链接如下: Python.CLF|Python.CLF下载_红软基地 http://www.rsdow ...
- 常用内置模块(一)——time、os、sys、random、shutil、pickle、json
常用内置模块 一.time模块 在python中,时间分为3种 1.时间戳: timestamp,从1970年1月1日到现在的秒数, 主要用于计算两个时间的差 2.localtime ...
- 快速调通支付宝当面付Demo
1.访问如下地址: https://auth.alipay.com/login/ant_sso_index.htm?goto=https%3A%2F%2Fopenhome.alipay.com%2Fp ...
- this与super的语法比较
this 代表当前对象 可以代表当前属性,当前方法,当前对象(整个自己). 作用:解决同名变量的同名问题,同明变量可能来源于父类,局部变量和成员变量... 语法使用:this( 实参... ); 调用 ...
- 备份一下alias喽
# 每次grep都显示出行号示出行号 alias grep="grep -n" # grep反向选择并显示行号显示行号 alias vgrep="grep -n -v&q ...
- C语言交换两个数的值
#include<stdio.h> int main() { //交换两个数的值 // 方法一 可读性最好 ; ; int temp ; temp = a; a = b; b = temp ...
- list采坑记录一下
List<Integer> cards = Lists.newArrayList(6,10,11,12,21,23,29,30,38,39,42,43,46,51,53,59,60);Li ...
- iftop简单使用
在linux下想查看当前与主机通信的IP有哪些?流量多少?怎么办?使用iftop吧,小巧实用的小工具.在排查问题的时候能起到大作用. centos安装 yum install iftop 界面如下: ...