Fox and Cross(#228(div2)B. )(四周上搜索)

#228(div2)B. Fox and Cross

B. Fox and Cross

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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

Examples

input

5
.#...
####.
.####
...#.
.....

output

YES

input

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

output

NO

input

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

output

YES

input

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

output

NO

input

3
...
...
...

output

YES
翻译
Fox Ciel 有一个有 n 行 n 列的板。因此,该板由 n × n 个单元组成。每个单元格包含一个符号“.”或一个符号“#”。 棋盘上的十字架是棋盘上正好五个单元格的连接集合,看起来像一个十字架。下图显示了它的外观。 Ciel 想在黑板上画几个(可能是零)个十字。每个十字必须正好覆盖五个带有符号“#”的单元格,并且任何带有符号“#”的单元格都必须属于某个十字。没有两个十字架可以共享一个单元格。 请告诉夏尔她是否可以按照描述的方式画十字。 输入 第一行包含一个整数 n (3 ≤ n ≤ 100)——棋盘的大小。 接下来的 n 行中的每一行都描述了棋盘的一行。第 i 行描述了棋盘的第 i 行,由 n 个字符组成。每个字符要么是一个符号“.”,要么是一个符号“#”。 输出 如果 Ciel 可以按照描述的方式绘制十字,则输出一行带有“YES”的内容。否则输出一行“NO”。

额,就是说看能不能形成十字架,但是不能重复利用,水题一道;

上ac代码。

 我的头像

 有事你就q我;QQ2917366383

学习算法

#include<bits/stdc++.h>
using namespace std;
int sum=0;
	char s[110][110];
int main()
{
	int n;cin>>n;

	for(int i=1;i<=n;i++)
	{
		scanf("%s",s[i]+1);
		for(int j=1;j<=n;j++)
		if(s[i][j]=='#')sum++;
	}
	if(sum%5!=0)
	cout<<"NO"<<endl;
	else
	{
		for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			 if( s[i][j]=='#')//亲,要注意这个哦,这是必要条件 
			 {
			 
			  if(s[i+1][j]=='#'&&s[i+2][j]=='#'&&s[i+1][j-1]=='#'&&s[i+1][j+1]=='#')
			  {
			  	  s[i+1][j]='.';s[i+2][j]='.';s[i+1][j-1]='.';s[i+1][j+1]='.';
			  	  s[i][j]='.';
			  }
			  
			  else
			  {
			  	cout<<"NO"<<endl;
			  return 0;
			  }
			  }			  
		 } 
	}
	cout<<"YES"<<endl;//听懂掌声 
	}
}

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
class Test10(): def setup_method(self): self.driver = webdriver.Firefox() self.vars = {} def teardown_method(self): self.driver.quit() def test_10(self): self.driver.get("http://oa.hhero.com.cn/?m=login")#访问网址 self.driver.set_window_size(1051, 798)#设置窗口大小 self.driver.find_element(By.NAME, "adminuser").click()#点击用户名输入框 self.driver.find_element(By.NAME, "adminuser").send_keys("admin")#输入用户名 self.driver.find_element(By.CSS_SELECTOR, "div:nth-child(3) .input").click()#点击密码输入框 self.driver.find_element(By.CSS_SELECTOR, "div:nth-child(3) .input").send_keys("a123456")#输入密码 self.driver.find_element(By.NAME, "button").click()#点击登录按钮 self.driver.implicitly_wait(5)#隐式等待5s self.driver.find_element(By.ID, "indesearchmenu").click()#点击搜索 self.driver.find_element(By.ID, "confirm_input").click()#点击搜索跳出的输入框 self.driver.find_element(By.ID, "confirm_input").send_keys("流程")#输入关键词"流程" self.driver.find_element(By.ID, "confirm_btn1").click()#点击确定 self.driver.find_element(By.LINK_TEXT, "流程模块列表").click()#点击"流程模块列表" self.driver.find_element(By.XPATH, "/html/body/table/tbody/tr/td[3]/div/div[4]/div/div[2]/div[1]/table/tbody/tr/td[2]/div/input").click()#在流程模块列表界面点击输入框 self.driver.find_element(By.XPATH, "/html/body/table/tbody/tr/td[3]/div/div[4]/div/div[2]/div[1]/table/tbody/tr/td[2]/div/input").send_keys("图书管理")#在输入框中输入图书管理 self.driver.find_element(By.CSS_SELECTOR, ".input-group-btn > .btn").click()#点击搜索 self.vars["types"] = self.driver.find_element(By.XPATH, "/html/body/table/tbody/tr/td[3]/div/div[4]/div/div[2]/div[3]/div[1]/table/tbody/tr/td[2]").text#获取其类型 print("{}".format(self.vars["types"]))#打印其类型
07-17
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

算法编程张老师

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值