結果

問題 No.179 塗り分け
ユーザー ser
提出日時 2017-12-16 12:41:38
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,337 bytes
コンパイル時間 665 ms
コンパイル使用メモリ 76,460 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-14 19:13:33
合計ジャッジ時間 2,215 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 39 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <climits>
#include <tuple>

using namespace std;

typedef vector<char> vc;
typedef vector<vector<char>> vvc;

int h, w;

bool check(const vector<char>& field, int mx, int my) {
    vector<char> f = field;
    for(int y=0; y<h; y++) {
        for(int x=0; x<w; x++) {
            if(f[x+y*w] == '#') {
                f[x+y*w] = 'R';

                int bx = x+mx;
                int by = y+my;
                if(!(0<=bx && bx<w && 0<=by && by<h)) return false;
                if(f[bx+by*w] == '#') {
                    f[bx+by*w] = 'B';
                } else {
                    return false;
                }
            }
        }
    }

    return true;
}

int main() {
    scanf("%d%d", &h, &w);
    getchar();

    auto field = vector<char>(w*h);
    for(int y=0; y<h; y++) {
        for(int x=0; x<w; x++) {
            scanf("%c", &field[x + y*w]);
        }
        getchar();
    }
    
    for(int mx=-w+1; mx<w; mx++) {
        for(int my=-h+1; my<h; my++) {
            if(mx==0 && my==0) continue;
            if(check(field, mx, my)) {
                printf("YES\n");
                return 0;
            }
        }
    }

    printf("NO\n");        
    
    return 0;
}
0