結果

問題 No.179 塗り分け
ユーザー rodea
提出日時 2020-12-29 17:14:58
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 2,008 bytes
コンパイル時間 1,130 ms
コンパイル使用メモリ 115,540 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-05 18:48:40
合計ジャッジ時間 3,901 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 38 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int h, w; cin>>h>>w;
    vector<string> s(h);
    for(int i=0; i<h; i++) cin>>s[i];

    for(int dy=-h; dy<=h; dy++){
        for(int dx=-w; dx<=w; dx++){
            if(dy == 0 && dx == 0) continue;
            vector<vector<int>> color(h, vector<int>(w, 0));
            bool painted = true;
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                    if(s[i][j] == '#' && color[i][j] == 0){
                        bool valid = false;
                        int ny = i + dy, nx = j + dx;
                        if(0 <= ny && ny < h && 0 <= nx && nx < w && s[ny][nx] == '#' && color[ny][nx] == 0){
                            color[i][j] = 1;
                            color[ny][nx] = 2;
                            valid = true;
                        }

                        if(!valid) painted = false;
                    }
                }
            }

            if(painted){
                cout << "YES" << endl;
                return 0;
            }
        }
    }

    cout << "NO" << endl;

    return 0;
}
0