結果

問題 No.179 塗り分け
ユーザー tkzw_21
提出日時 2015-04-05 23:51:54
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 44 ms / 3,000 ms
コード長 880 bytes
コンパイル時間 1,452 ms
コンパイル使用メモリ 163,920 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-23 14:24:51
合計ジャッジ時間 3,285 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int h,w;
bool func(int y,int x,vector<string> s){
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j] == '#'){
                if(i+y < 0 || j+x < 0 || i+y >= h || j+x >= w)return false;
                if(s[i+y][j+x] != '#')return false;
                s[i+y][j+x] = '.';
            }
        }
    }
    return true;
}

int main(void) {
    cin >> h >> w;
    vector<string> s(h);
    for(int i=0;i<h;i++){
        cin >> s[i];
    }
    int cnt = 0;
    for(int i=0;i<h;i++){
    	for(int j=0;j<w;j++){
    		if(s[i][j] == '#')cnt++;
    	}
    }
    bool f = false;
    for(int i=-h;i<h;i++){
        for(int j=-h;j<w;j++){
            if(i == 0 && j == 0)continue;
            f |= func(i,j,s);
        }
    }
    cout << ( (f && cnt>=2) ?"YES":"NO") << endl;
    return 0;
}
0