結果

問題 No.179 塗り分け
ユーザー なおなお
提出日時 2015-04-06 00:53:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 63 ms / 3,000 ms
コード長 1,285 bytes
コンパイル時間 1,358 ms
コンパイル使用メモリ 150,448 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-30 20:36:51
合計ジャッジ時間 3,398 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 32 ms
4,380 KB
testcase_09 AC 31 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 32 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 34 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 35 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 9 ms
4,376 KB
testcase_27 AC 51 ms
4,380 KB
testcase_28 AC 6 ms
4,376 KB
testcase_29 AC 58 ms
4,376 KB
testcase_30 AC 31 ms
4,376 KB
testcase_31 AC 63 ms
4,376 KB
testcase_32 AC 21 ms
4,376 KB
testcase_33 AC 55 ms
4,380 KB
testcase_34 AC 17 ms
4,380 KB
testcase_35 AC 59 ms
4,380 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 1 ms
4,376 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 AC 3 ms
4,380 KB
testcase_44 AC 8 ms
4,376 KB
testcase_45 AC 2 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define REP(i, n)           for(int(i)=0;(i)<(n);++(i))
#define FOR(i, f, t)        for(int(i)=(f);(i)<(t);(++i))
#define RREP(i, n)          for(int(i)=(n)-1;(i)>=0;--(i))
const int MOD = int(1e9+7);


int main(){
    do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0);
    int H,W;
    cin >> H >> W;

    vector<string> v;
    REP(i,H){
        string s; cin >> s;
        v.push_back(s);
    }
    int t = 0;
    REP(y,H)REP(x,W){
        if(v[y][x] == '#') t++;
    }
    if(t%2 || t == 0){
        cout << "NO" << endl;
        return 0;
    }

    REP(y,H) for(int x = -W+1; x < W; x++){
        if(y == 0 && x == 0) continue;
        vector<string> w = v;
        int c = 0;
        REP(y2,H)REP(x2,W){
            int x3 = x2+x, y3 = y2+y;
            if(x3<0||y3<0||x3>=W||y3>=H) continue;
            if(w[y2][x2] == '#' && w[y3][x3] == '#'){
                w[y2][x2] = w[y3][x3] = '$';
                c += 2;
            }
        }
        if(t == c){
            cerr << x << ":" << y << endl;
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
    return 0;
}
0