結果
| 問題 | 
                            No.179 塗り分け
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2023-01-27 20:10:59 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 191 ms / 3,000 ms | 
| コード長 | 1,119 bytes | 
| コンパイル時間 | 1,856 ms | 
| コンパイル使用メモリ | 202,616 KB | 
| 最終ジャッジ日時 | 2025-02-10 07:23:20 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 6 | 
| other | AC * 40 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
    int h,w,n=0;
    cin>>h>>w;
    vector<string> s(h);
    for(int i=0; i<h; i++){
        cin>>s[i];
        for(int j=0; j<w; j++){
            if(s[i][j]=='#') n++;
        }
    }
    for(int x=-h; x<=h; x++){
        for(int y=-w; y<=w; y++){
            if(x==0 && y==0) continue;
            vector<vector<bool>> vst(h,vector<bool>(w));
            int pnt=0;
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                    if(s[i][j]!='#') continue;
                    int xx=i+x;
                    int yy=j+y;
                    if(xx<0 || xx>=h || yy<0 || yy>=w){
                        continue;
                    }
                    if(s[i][j]=='#' && s[xx][yy]=='#' && !vst[i][j] && !vst[xx][yy]){
                        vst[i][j]=vst[xx][yy]=1;
                        pnt+=2;
                    }
                }
            }
            if(pnt==n && pnt>0){
                cout<<"YES"<<endl;
                return 0;
            }
        }
    }
    cout<<"NO"<<endl;
    return 0;
}