#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; }
原文:http://www.cnblogs.com/hyfer/p/5904405.html