結果
| 問題 | 
                            No.179 塗り分け
                             | 
                    
| コンテスト | |
| ユーザー | 
                             kpinkcat
                         | 
                    
| 提出日時 | 2023-11-04 20:55:37 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 22 ms / 3,000 ms | 
| コード長 | 1,606 bytes | 
| コンパイル時間 | 2,020 ms | 
| コンパイル使用メモリ | 198,468 KB | 
| 最終ジャッジ日時 | 2025-02-17 19:18:20 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 6 | 
| other | AC * 40 | 
ソースコード
#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<math.h>
#include<bitset>
using ll = long long;
using namespace std;
int main(){
    int h, w;
    cin >> h >> w;
    string s;
    vector<string> v(h);
    for (int i = 0; i < h; i++) cin >> v[i];
    for (int i = 0; i < h; i++){
        for (int j = -w + 1; j < w; j++){
            int dy = i, dx = j;
            bool no = false, yes = false;
            vector<string> tmp = v;
            if (dy == 0 && dx == 0) continue;
            for (int k = 0; k < h; k++){
                for (int l = 0; l < w; l++){
                    if (tmp[k][l] == '#'){
                        tmp[k][l] = 'R';
                        if (k + dy >= 0 && k + dy < h && l + dx >= 0 && l + dx < w){
                            if(v[k+dy][l+dx] == '#'){
                                tmp[k+dy][l+dx] = 'B';
                                yes = true;
                            } else {
                                no = true;
                                yes = false;
                                break;
                            }
                        } else {
                            no = true;
                            yes = false;
                            break;
                        }
                    }
                }
                if (no) break;
            }
            if (yes){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
}
            
            
            
        
            
kpinkcat