Codeforces Round #228 (Div. 2) B. Fox and Cross

OpenSoucre發表於2014-02-10
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<string> board(n);
    int cnt = 0;
    for(int i = 0 ; i < n; ++ i ){
        cin >> board[i];
    }

    for(int i = 1 ; i < n-1; i ++ ){
        for(int j = 1 ; j < n-1; j ++ ){
            if(board[i][j] == '#' &&  board[i-1][j] == '#' &&
                 board[i+1][j]=='#' && board[i][j-1]=='#' && board[i][j+1]=='#'){
                board[i][j]='.';
                board[i+1][j]='.';
                board[i-1][j]='.';
                board[i][j-1]='.';
                board[i][j+1]='.';
            }
        }
    }

    for(int i = 0 ; i < n; ++i){
        if(board[i].find('#')!=string::npos){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

 

相關文章