結果

問題 No.179 塗り分け
ユーザー heabiheabi
提出日時 2020-11-21 15:32:43
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,504 bytes
コンパイル時間 1,610 ms
コンパイル使用メモリ 173,004 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-30 21:54:40
合計ジャッジ時間 6,125 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 21 ms
4,380 KB
testcase_06 AC 6 ms
4,380 KB
testcase_07 WA -
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 5 ms
4,376 KB
testcase_10 AC 53 ms
4,380 KB
testcase_11 AC 46 ms
4,376 KB
testcase_12 AC 181 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 WA -
testcase_18 AC 85 ms
4,376 KB
testcase_19 AC 78 ms
4,376 KB
testcase_20 AC 157 ms
4,376 KB
testcase_21 AC 144 ms
4,376 KB
testcase_22 AC 141 ms
4,376 KB
testcase_23 AC 54 ms
4,380 KB
testcase_24 AC 139 ms
4,380 KB
testcase_25 AC 71 ms
4,380 KB
testcase_26 AC 78 ms
4,380 KB
testcase_27 AC 208 ms
4,384 KB
testcase_28 AC 129 ms
4,376 KB
testcase_29 AC 256 ms
4,376 KB
testcase_30 AC 65 ms
4,380 KB
testcase_31 AC 279 ms
4,380 KB
testcase_32 AC 80 ms
4,380 KB
testcase_33 AC 251 ms
4,376 KB
testcase_34 AC 103 ms
4,376 KB
testcase_35 AC 272 ms
4,380 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 2 ms
4,384 KB
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 8 ms
4,380 KB
testcase_44 AC 32 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++;

    for (ll dy = -H; dy <= H; dy++) {
        for (ll dx = -W; dx <= W; dx++) {
            if (dy == 0 && dx == 0) continue;
            vector<vector<bool>> seen(H, vector<bool>(W));
            bool can = true;
            rep(i, H) {
                rep(j, W) {
                    if (s[i][j] == '.') continue;
                    if (seen[i][j]) continue;
                    if (0 <= i + dy && i + dy < H && 0 <= j + dx &&
                        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