繁华模拟赛 找十字架

#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
char s[205][205],cmd;
int main(){
    freopen("puzzle.in","r",stdin);
    freopen("puzzle.out","w",stdout);
    cin>>n;
    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= n;j++){
            scanf(" %c",&cmd);
            s[i][j] = cmd;
        }
    }
    for(int i = 2;i <= n-1;i++){
        for(int j = 2;j <= n-1;j++){
            if(s[i][j] == '#' && s[i-1][j] == '#' && s[i+1][j] == '#' && s[i][j-1] == '#' && s[i][j+1] == '#'){
                s[i][j] = s[i-1][j] = s[i+1][j] = s[i][j-1] = s[i][j+1] = '.';
            }
        }
    }
    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= n;j++){
            if(s[i][j] == '#'){
                cout<<"NO";
                return 0;
            }
        }
    }
    cout<<"YES";
    return 0;
} 

 

posted @ 2016-09-24 22:56  ACforever  阅读(237)  评论(0编辑  收藏  举报