Codeforces 389B(十字模拟)
| Time Limit: 1000MS | Memory Limit: 262144KB | 64bit IO Format: %I64d & %I64u |
Description
Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a symbol '#'.
A cross on the board is a connected set of exactly five cells of the board that looks like a cross. The picture below shows how it looks.
Ciel wants to draw several (may be zero) crosses on the board. Each cross must cover exactly five cells with symbols '#', and any cell with symbol '#' must belong to some cross. No two crosses can share a cell.
Please, tell Ciel if she can draw the crosses in the described way.
Input
The first line contains an integer n (3 ≤ n ≤ 100) — the size of the board.
Each of the next n lines describes one row of the board. The i-th line describes the i-th row of the board and consists of n characters. Each character is either a symbol '.', or a symbol '#'.
Output
Output a single line with "YES" if Ciel can draw the crosses in the described way. Otherwise output a single line with "NO".
Sample Input
5
.#...
####.
.####
...#.
.....
YES
4
####
####
####
####
NO
6
.#....
####..
.####.
.#.##.
######
.#..#.
YES
6
.#..#.
######
.####.
.####.
######
.#..#.
NO
3
...
...
...
YES
Hint
In example 1, you can draw two crosses. The picture below shows what they look like.
In example 2, the board contains 16 cells with '#', but each cross contains 5. Since 16 is not a multiple of 5, so it's impossible to cover all.
Source
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <math.h>
using namespace std;
typedef long long ll;
int main()
{
int i,j,n,sum,flag;
char c[][];
while (cin>>n)
{
sum=;
for (i=;i<n;i++)
for (j=;j<n;j++)
{
cin>>c[i][j];
if (c[i][j]=='#') sum++;
}
for (i=;i<n;i++)
for (j=;j<n;j++)
{
if (c[i][j]=='#'&&c[i+][j]=='#'&&c[i+][j]=='#'&&c[i+][j+]=='#'&&c[i+][j-]=='#')
{
c[i][j]='.';
c[i+][j]='.';
c[i+][j]='.';
c[i+][j+]='.';
c[i+][j-]='.';
sum-=;
}
}
//cout<<sum<<endl;
if (sum==)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
} return ;
}
Codeforces 389B(十字模拟)的更多相关文章
- codeforces 591B Rebranding (模拟)
Rebranding Problem Description The name of one small but proud corporation consists of n lowercase E ...
- Codeforces 626B Cards(模拟+规律)
B. Cards time limit per test:2 seconds memory limit per test:256 megabytes input:standard input outp ...
- Codeforces 631C. Report 模拟
C. Report time limit per test:2 seconds memory limit per test:256 megabytes input:standard input out ...
- Codeforces 679B. Barnicle 模拟
B. Barnicle time limit per test: 1 second memory limit per test :256 megabytes input: standard input ...
- CodeForces 382C【模拟】
活生生打成了大模拟... #include <bits/stdc++.h> using namespace std; typedef long long LL; typedef unsig ...
- codeforces 719C (复杂模拟-四舍五入-贪心)
题目链接:http://codeforces.com/problemset/problem/719/C 题目大意: 留坑...
- CodeForces 705C Thor (模拟+STL)
题意:给定三个操作,1,是x应用产生一个通知,2,是把所有x的通知读完,3,是把前x个通知读完,问你每次操作后未读的通知. 析:这个题数据有点大,但可以用STL中的队列和set来模拟这个过程用q来标记 ...
- CodeForces 697B Barnicle 模拟
强行模拟 纪念一下…… #include<stdio.h> #include<iostream> #include<algorithm> #include<m ...
- CodeForces 709B Checkpoints 模拟
题目大意:给出n个点的坐标,和你当前的坐标,求走过n-1个点的最短路程. 题目思路:走过n-1个点,为了使路程更短,那么不走的点只可能第一个点或最后一个点.模拟就行了,比较恶心. #include&l ...
随机推荐
- hihoCoder 1195 高斯消元.一
传送门 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Ho:喂不得了啦,那边便利店的薯片半价了! 小Hi:啥?! 小Ho:那边的便利店在打折促销啊. 小Hi:走走走, ...
- MVC执行顺序
MVC在底层和传统的asp.net是一致的,在底层之上,相关流程如下: 1)Global.asax里,MvcApplication对象的Application_Start()事件中,调用 RouteC ...
- Integer.valueOf(String) 方法之惑
本文由 ImportNew - 靳禹 翻译自 stackoverflow.欢迎加入翻译小组.转载请见文末要求. 有个仁兄在 StackOverflow 上发起了一个问题,是这么问的: “ 我被下面的代 ...
- -----------------------------------项目中整理的非常有用的PHP函数库(一)-----------------------------------------------------
1.PHP加密解密 PHP加密和解密函数可以用来加密一些有用的字符串存放在数据库里,并且通过可逆解密字符串,该函数使用了base64和MD5加密和解密. function encryptDecrypt ...
- tp auth 转载保存
PS:最近需要做一个验证用户权限的功能,在官方和百度看了下,发现大家都是用auth来做验证,官方有很多auth的使用教程,但是都不全面,我也提问了几个关于auth的问题 也没人来回答我,无奈只好一步步 ...
- express快速搭建web server
安装express4.x npm install -g express npm install -g express-generator //express命令行工具在4.x分离出来了 express ...
- CentOS 7 使用经验(更新中)
首先说一下写这篇博客的初衷. 由于公司这一期的产品准备支持的环境有CentOS 7.MySql 5.6.Java 8.Tomcat 8等等,并且因为人员严重不足,我本月的开发任务在原有的基础上又加上了 ...
- Nonove js timer 计时器
<html> <head> <title> Nonove js timer 计时器 </title> </head> <body> ...
- 数据库客户端SQLeonardo的使用
数据库客户端SQLeonardo的使用 这篇文章要介绍SQLeonardo.我使用了一下,挺不错,一个jar包,加载不同的驱动之后,可以连接很多类型的数据库,我只连接了HSQL和Oracle ...
- ngrok反向代理
关于ngrok ngrok 是一个反向代理,通过在公共的端点和本地运行的 Web 服务器之间建立一个安全的通道.ngrok 可捕获和分析所有通道上的流量,便于后期分析和重放. 为什么使用ngrok? ...