Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u

Submit Status

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

Input
5
.#...
####.
.####
...#.
.....
Output
YES
Input
4
####
####
####
####
Output
NO
Input
6
.#....
####..
.####.
.#.##.
######
.#..#.
Output
YES
Input
6
.#..#.
######
.####.
.####.
######
.#..#.
Output
NO
Input
3
...
...
...
Output
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(十字模拟)的更多相关文章

  1. codeforces 591B Rebranding (模拟)

    Rebranding Problem Description The name of one small but proud corporation consists of n lowercase E ...

  2. Codeforces 626B Cards(模拟+规律)

    B. Cards time limit per test:2 seconds memory limit per test:256 megabytes input:standard input outp ...

  3. Codeforces 631C. Report 模拟

    C. Report time limit per test:2 seconds memory limit per test:256 megabytes input:standard input out ...

  4. Codeforces 679B. Barnicle 模拟

    B. Barnicle time limit per test: 1 second memory limit per test :256 megabytes input: standard input ...

  5. CodeForces 382C【模拟】

    活生生打成了大模拟... #include <bits/stdc++.h> using namespace std; typedef long long LL; typedef unsig ...

  6. codeforces 719C (复杂模拟-四舍五入-贪心)

    题目链接:http://codeforces.com/problemset/problem/719/C 题目大意: 留坑...

  7. CodeForces 705C Thor (模拟+STL)

    题意:给定三个操作,1,是x应用产生一个通知,2,是把所有x的通知读完,3,是把前x个通知读完,问你每次操作后未读的通知. 析:这个题数据有点大,但可以用STL中的队列和set来模拟这个过程用q来标记 ...

  8. CodeForces 697B Barnicle 模拟

    强行模拟 纪念一下…… #include<stdio.h> #include<iostream> #include<algorithm> #include<m ...

  9. CodeForces 709B Checkpoints 模拟

    题目大意:给出n个点的坐标,和你当前的坐标,求走过n-1个点的最短路程. 题目思路:走过n-1个点,为了使路程更短,那么不走的点只可能第一个点或最后一个点.模拟就行了,比较恶心. #include&l ...

随机推荐

  1. easyui之datagrid的使用

    http://www.cnblogs.com/ruanmou001/p/3840954.html 一.神马是easyui jQuery EasyUI是一组基于jQuery的UI插件集合,而jQuery ...

  2. MyEclipse------遍历某个路径下的(所有或特定)文件和目录

    usebean包(自己定义的,在src文件夹下面)里的java文件 FileAccept.java package usebean; import java.io.File; import java. ...

  3. unity3d DefineManager 全局宏定义

    /** * Editor Wizard for easily managing global defines in Unity * Place in Assets/Editor folder, or ...

  4. nginx负载均衡的配置方法

    upstream www.***.com { server ; server ; server ; } server { listen ; server_name www.***.com; #char ...

  5. Linux中iptables设置详细(转)

    无论如何,iptables是一个需要特别谨慎设置的东西,万一服务器不在你身边,而你贸然设置导致无法SSH,那就等着被老板骂吧,呵呵... 以下内容是为了防止这种情况发生而写的,当然很初级,不过一般服务 ...

  6. 解决在IE中返回JSON格式的数据时提示下载的问题

    如题,以ASP.NET MVC为例,解决办法如下: 控制器中: public JsonResult Test() { return Json(json, "text/html"); ...

  7. [Socket网络编程]由于套接字没有连接并且(当使用一个 sendto 调用发送数据报套接字时)没有提供地址,发送或接收数据的请求没有被接受。

    原文地址:http://blog.sina.com.cn/s/blog_70bf579801017ylu.html,记录在此方便查看 解决办法: MSDN的说明: Close 方法可关闭远程主机连接, ...

  8. php面试题之四——PHP面向对象(基础部分)

    四.PHP面向对象 1. 写出 php 的 public.protected.private 三种访问控制模式的区别(新浪网技术部) public:公有,任何地方都可以访问 protected:继承, ...

  9. gen already exists but is not a source folder. Convert to a source folder or rename it.

    异常提示: gen already exists but is not a source folder. Convert to a source folder or rename it.   错误原因 ...

  10. [Effective JavaScript 笔记]第52条:数组字面量优于数组构造函数

    js的优雅很大程序要归功于程序中常见的构造块(Object,Function及Array)的简明的字面量语法.字面量是一种表示数组的优雅方法. var a=[1,2,3,5,7,8]; 也可以使用构造 ...