题目链接: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的更多相关文章

  1. 基于Picture Library创建的图片文档库中的上传多个文件功能(upload multiple files)报错怎么解决?

    复现过程 首先,我创建了一个基于Picture Library的图片文档库,名字是 Pic Lib 创建完毕后,我点击它的Upload 下拉菜单,点击Upload Picture按钮 在弹出的对话框中 ...

  2. MFC Picture控件加载图片

    CStatic *pPic = (CStatic*)GetDlgItem(IDC_PICTURE); CBitmap bitmap; bitmap.LoadBitmapW(IDB_BITMAP2); ...

  3. [POJ1177]Picture

    [POJ1177]Picture 试题描述 A number of rectangular posters, photographs and other pictures of the same sh ...

  4. Codeforce - Street Lamps

    Bahosain is walking in a street of N blocks. Each block is either empty or has one lamp. If there is ...

  5. USACO 5.5 Picture(周长并)

    POJ最近做过的原题. /* ID: cuizhe LANG: C++ TASK: picture */ #include <cstdio> #include <cstring> ...

  6. 彩色照片转换为黑白照片(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 ...

  7. HDU 1828 Picture(线段树扫描线求周长)

    Picture Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Su ...

  8. don't forget the bigger picture

    Imagine a circle that contains all of human knowledge: By the time you finish elementary school, you ...

  9. 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 ...

随机推荐

  1. The document cannot be opened. It has been renamed, deleted or moved.

    In the Individual components section of the Visual Studio Installer, make sure that Razor Language S ...

  2. Mosaic

    Mosaic 是最古老的WEB浏览器,这是个套件FOR WINDOWS(包括TCP/IP,拨号,EMAIL等).

  3. 去BAT面试完的Mysql面试题总结(55道,带完整答案)

    1.一张表里面有ID自增主键,当insert了17条记录之后,删除了第15,16,17条记录,再把mysql重启,再insert一条记录,这条记录的ID是18还是15 ? 2.mysql的技术特点是什 ...

  4. 《Javascript权威指南》学习笔记之十七:BOM新成就(1)--client存储数据(Storage实现)

    版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/u011043843/article/details/30255899     数据构成了web网站的 ...

  5. 为IIS服务器配置SSL,并设置为默认使用https协议访问网站

    要使网站支持https协议,需要SSL证书,我的服务器和域名都是在阿里云购买的,所以这里我演示阿里云获取SSL证书的方法 我先说下我的服务器环境:windows server 2012 + IIS8. ...

  6. shell专用参数变量

  7. Keepalived高可用服务

    Keepalived高可用服务 避免负载均衡服务出现单点问题 高可用服务原理 Keepalived的工作原理: Keepalived高可用对之间是通过VRRP通信的,因此,我从 VRRP开始了解起: ...

  8. 华视身份证读卡器获取uid号vue单文件组件版本

    <template> <div id="app" ref="app"> <object ref="CertCtl&quo ...

  9. Docker拉取镜像时错误解决办法

    拉取docker中的镜像时报错: [root@master ~]# docker pull docker.io/centos:latest Trying to pull repository dock ...

  10. vue 使用Animate.css库

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...