結果

問題 No.179 塗り分け
ユーザー 👑 zeronosu77108zeronosu77108
提出日時 2021-01-16 17:27:02
言語 C++17(clang)
(14.0.0 + boost 1.83.0)
結果
AC  
実行時間 89 ms / 3,000 ms
コード長 1,804 bytes
コンパイル時間 2,028 ms
コンパイル使用メモリ 105,260 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 15:23:33
合計ジャッジ時間 5,545 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 9 ms
4,380 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 84 ms
4,380 KB
testcase_09 AC 83 ms
4,380 KB
testcase_10 AC 44 ms
4,376 KB
testcase_11 AC 37 ms
4,376 KB
testcase_12 AC 73 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 44 ms
4,376 KB
testcase_19 AC 41 ms
4,380 KB
testcase_20 AC 78 ms
4,380 KB
testcase_21 AC 85 ms
4,380 KB
testcase_22 AC 89 ms
4,380 KB
testcase_23 AC 43 ms
4,380 KB
testcase_24 AC 85 ms
4,376 KB
testcase_25 AC 44 ms
4,376 KB
testcase_26 AC 49 ms
4,376 KB
testcase_27 AC 84 ms
4,380 KB
testcase_28 AC 45 ms
4,380 KB
testcase_29 AC 84 ms
4,376 KB
testcase_30 AC 59 ms
4,376 KB
testcase_31 AC 84 ms
4,380 KB
testcase_32 AC 54 ms
4,376 KB
testcase_33 AC 84 ms
4,376 KB
testcase_34 AC 50 ms
4,376 KB
testcase_35 AC 85 ms
4,376 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 AC 4 ms
4,376 KB
testcase_44 AC 12 ms
4,376 KB
testcase_45 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//
// Created by zeronosu77108 on Jan 15, 2021.
//
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>
#include <complex>
#include <optional>
#include <climits>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<(v)<<endl;}

int main() {
    int h, w;
    cin >> h >> w;

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

    {
        int cnt = 0;
        for (int i=0; i<h; i++) cnt += count(s[i].begin(), s[i].end(), '#');
        if (cnt<2) {
            cout << "NO" << endl;
            return 0;
        }
    }

    for (int dy=-h; dy<h; dy++) {
        for (int dx=-w; dx<w; dx++) {
            if (dy==0 && dx==0) continue;
            vector used(h, vector(w, false));

            bool f = true;
            for (int i=0; i<h; i++) {
                for (int j=0; j<w; j++) {
                    if (s[i][j] == '.') continue;
                    if (used[i][j]) continue;
                    used[i][j] = true;

                    if (i+dy<0 || h<=i+dy || j+dx<0 || w<=j+dx) {f=false; break; }
                    if (s[i+dy][j+dx] == '.') {f=false; break;}
                    used[i+dy][j+dx] = true;
                }
                if (!f) break;
            }

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

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