模拟-codeforces-389B-Fox and Cross

Fox and Cross

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

4
####
####
####
####

6
.#....
####..
.####.
.#.##.
######
.#..#.

6
.#..#.
######
.####.
.####.
######
.#..#.

3
...
...
...

Sample Output

YES

NO

YES

NO

YES

 大意:一个 Cross要占据5个格子,要求:cross之间不能共用格子;cross只能占据形状为'#'的格子。

问你能不能画cross,把‘#’形状的格子用完。

解决:从上到下,从左至右,看当前格子能不能作为cross的五块之中的第一块。若可以,进一步检查。若仍可以,将五个格子从'#'置为'.'。看最后有没有剩余的'#'状格子。

 

 

 

时间: 2024-09-10 11:32:40

模拟-codeforces-389B-Fox and Cross的相关文章

Codeforces 510 A.Fox and Snake

题目链接:http://codeforces.com/contest/510/problem/A A. Fox And Snake time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Fox Ciel starts to learn programming. The first task is drawing a fox! However

优先队列+模拟-Fox and Number Game

codeforces-Fox and Number Game 题目地址:http://codeforces.com/contest/389/problem/ATime Limit: 1000msFox Ciel is playing a game with numbers now. Ciel has n positive integers: x1, x2, ..., xn. She can do the following operation as many times as needed: s

【CF 676B Pyramid of Glasses】模拟,递归

题目链接:http://codeforces.com/problemset/problem/676/B 题意:一个n层的平面酒杯金字塔,如图,每个杯子的容量相同.现在往最顶部的一个杯子倒 t 杯酒,求流动结束后有多少个杯子被装满. 思路:每个局部的两代三个杯子的流动过程是一致的,因此可以用递归来模拟求解. 具体为:设add(cur, i, l)执行"往第 i 个杯子倒cur量的酒",附加信息: i 位于第 l 层.若执行完剩余了surplus量的酒,则往 i 的下一层左右两侧的杯子各倒

Codeforces 452 A. Eevee

题目链接:http://codeforces.com/contest/452/problem/A 提示:模拟题,水 #include <iostream> #include <cstring> #include <cstdio> using namespace std; char s[20]; int main() { int m; while(cin>>m>>s) { int len=strlen(s); if((s[0]=='j'||s[0]

跨浏览器 HTML5 postMessage 方法以及 message 事件模拟实现

postMessage 方法 JSONP 技术不一样,前者是前端擅长跨域文档数据即时通讯,后者擅长针对跨域服务端数据通讯,postMessage 应用场景能说明这个区别: 应用场景举例 1.webOS 使用 iframe 嵌入第三方应用,此时 webOS 与应用需要实时接收/发送各自的消息与响应事件. 2.页面弹出一个由 iframe 层,嵌入第三方提供的图片上传页面,文件上传完毕后需要获取返回图片地址插入到编辑器. 3.iframe 跨域高度自适应. HTML5 postMessage 方法

[原创]php+ajax实现模拟Win文件管理系统七

[原创]php+ajax实现模拟Win文件管理系统 // 本教程由本站原创,转载请注明来处 作者:www.111cn.net 邮箱:drise@163.com QQ:271728967 // 最后一个文件就是js.js文件了. var xmlhttp=false;  function aa(obj)  {   obj.className='aa';   obj.onblur=function(){obj.className='bb';}  }  function resizepic(thispi

阿里云发布异构计算产品家族,你可以在上面模拟核爆炸

本文讲的是阿里云发布异构计算产品家族,你可以在上面模拟核爆炸 数据.算力和算法,这是人工智能发展的三大要素. 近一年来,人工智能迎来了史上第三次热潮.移动互联网时代沉淀下来的大量数据和GPU近几年的快速发展,让学界和业界相信,这人工智能时代真的要来了. 由于人工智能模型训练对算力的要求,原有的通用型CPU架构无法满足,不少企业或科研机构在训练模型的时候会通过采用和主处理器(CPU)不同架构的加速器件(也就是所谓"异构"),如GPU.FPGA.ASIC等器件,提供高密度并行计算的运算能力

新浪微博模拟登录(Java)

     使用HttpClient模拟新浪微博登录,贴在这里做个备忘,也希望能帮助到有这方面需求的童鞋们,代码如下:        Java代码   package com.yida.spider4j.crawler.test.sina;      import java.io.UnsupportedEncodingException;   import java.math.BigInteger;   import java.net.URLEncoder;   import java.secur

Excel工作表中使用模拟运算表的方法

  Excel工作表中使用模拟运算表的方法          1.创建一个新的Excel工作表,并在工作表输入数据.在B9单元格中输入提成金额的计算公式"=$B$2*$B$3",如图1所示. 图1 创建工作表并输入公式 2.在B10:B23单元格区域中输入提成比率,然后选择用于创建模拟运算表的单元格B9:I23,在"数据"选项卡的"数据工具"组中单击"模拟分析"按钮,在打开的下拉列表中选择"模拟运算表"选项