結果

問題 No.179 塗り分け
ユーザー heabiheabi
提出日時 2020-11-21 15:10:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,442 bytes
コンパイル時間 1,586 ms
コンパイル使用メモリ 174,576 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 21:53:29
合計ジャッジ時間 3,828 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
#define vvvvll vector<vector<vector<vector<ll>>>>
#define vvvll vector<vector<vector<ll>>>
#define vvll vector<vector<ll>>
#define vll vector<ll>
#define pqll priority_queue<ll>
#define pqllg priority_queue<ll, vector<ll>, greater<ll>>

constexpr ll INF = (1ll << 60);
constexpr ll mod = 1000000007;  // 998244353;
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

void pt_vvll(vvll v) {
    ll vs = v.size(), vs0 = v[0].size();
    rep(i, vs) {
        rep(j, vs0) {
            cout << v[i][j];

            if (j != vs0 - 1)
                cout << " ";
            else
                cout << "\n";
        }
    }
}
void pt_vll(vll v) {
    ll vs = v.size();
    rep(i, vs) {
        cout << v[i];
        if (i == vs - 1)
            cout << "\n";
        else
            cout << " ";
    }
}

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

    ll H, W;
    cin >> H >> W;
    vector<string> s(H);
    rep(i, H) { cin >> s[i]; }
    ll cnt = 0;
    rep(i, H) rep(j, W) if (s[i][j] == '#') cnt++;
    if (cnt <= 2 || cnt % 2 == 1) {
        cout << "NO\n";
        return 0;
    }

    rep(dy, H) {
        rep(dx, W) {
            if (dy == 0 && dx == 0) continue;
            vector<vector<bool>> seen(H, vector<bool>(W));
            bool can = true;
            rep(i, H) {
                rep(j, W) {
                    if (seen[i][j]) continue;
                    if (i + dy < H && j + dx < W && s[i][j] == '#' &&
                        s[i + dy][j + dx] == '#' && !seen[i + dy][j + dx]) {
                        seen[i][j] = true;
                        seen[i + dy][j + dx] = true;
                    }
                }
            }

            rep(i, H) rep(j, W) {
                if (s[i][j] == '#' && !seen[i][j]) can = false;
            }

            if (can) {
                // cout << dy << " " << dx << "\n";
                cout << "YES\n";
                return 0;
            }
        }
    }
    cout << "NO\n";
    return 0;
}
0