• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
HaibaraAi
博客园    首页    新随笔    联系   管理    订阅  订阅

Codeforce Round #227 Div2 B

 

Sponsored by
In English По-русски
HaibaraAi | Logout
 
 
 
 
 
  • Home
  • Contests
  • Gym
  • Problemset
  • Groups
  • Rating
  • Help

 
 
Codeforces Round #228 (Div. 2)
Finished
Practice
Add to favourites
 
 
→ Practice
 
You are registered for practice. You can solve problems unofficially. Results can be found in the contest status and in the bottom of standings.
 
 
→ Submit?
 
Language:
Choose file:
Be careful: there is 50 points penalty for submission which fails the pretests or resubmission (except failure on the first test, denial of judgement or similar verdicts). "Passed pretests" submission verdict doesn't guarantee that the solution is absolutely correct and it will pass system tests.
 
 
→ Last submissions
 
SubmissionTimeVerdict
5911585 02/06/2014 08:16PM Accepted
5911556 02/06/2014 08:11PM Wrong answer on test 1
5911531 02/06/2014 08:06PM Wrong answer on test 1
 
 
→ Problem tags
 
 
 
 
 
greedy
 
 
 
 
implementation
No tag edit access
 
 
→ Contest materials
 
  • Announcement
     
  • Tutorial
     
  •  
     
     
  • Problems
  • Submit
  • My submissions
  • Status
  • Hacks
  • Room
  • Standings
  • Custom test
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".

Sample test(s)
Input
5 .#... ####. .#### ...#. .....
Output
YES
Input
4 #### #### #### ####
Output
NO
Input
6 .#.... ####.. .####. .#.##. ###### .#..#.
Output
YES
Input
6 .#..#. ###### .####. .####. ###### .#..#.
Output
NO
Input
3 ... ... ...
Output
YES
Note

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.


Codeforces (c) Copyright 2010-2014 Mike Mirzayanov
The only programming contests Web 2.0 platform
Server time: 02/07/2014 12:45AM (p1).
 
 
 
 1 #pragma comment(linker,"/STACK:102400000,102400000")
 2 #include <cstdio>
 3 #include <vector>
 4 #include <cmath>
 5 #include <queue>
 6 #include <set>
 7 #include <cstring>
 8 #include <iostream>
 9 #include <algorithm>
10 using namespace std;
11 #define INF 0x7fffffff 
12 #define mod 1000000007
13 #define ll long long
14 #define maxn 205
15 #define pi acos(-1.0)  
16 int n, m, k, c,t,b;
17 char s[maxn][maxn];
18 int main(){
19     scanf("%d", &n);
20     int flag = 1;
21     for (int i = 0; i < n; i++)scanf("%s", s[i]);
22     for (int i = 0; i < n; i++)
23         for (int j = 0; j < n; j++)
24             if (s[i][j] == '#'){
25                 if (j+1<n&&i+2<n&&j-1>=0&&s[i+1][j] == '#'&&s[i+2][j] == '#'&&s[i+1][j-1] == '#'&&s[i+1][j+1] == '#'){
26                     s[i+1][j] = '.';
27                     s[i+2][j] = '.';
28                     s[i+1][j-1] = '.';
29                     s[i+1][j+1] = '.';
30                     s[i][j] = '.';
31                 }
32                 else flag = 0;
33             }
34     printf(flag ? "YES\n" : "NO\n");
35     return 0;
36 }
View Code
posted @ 2014-02-07 04:46  HaibaraAi  阅读(123)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3