結果

問題 No.179 塗り分け
ユーザー pyonthpyonth
提出日時 2021-02-02 21:18:25
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,523 bytes
コンパイル時間 2,050 ms
コンパイル使用メモリ 204,648 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-12 11:24:32
合計ジャッジ時間 4,948 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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 11 ms
4,380 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 WA -
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 19 ms
4,376 KB
testcase_11 AC 16 ms
4,376 KB
testcase_12 AC 66 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 WA -
testcase_18 AC 36 ms
4,376 KB
testcase_19 AC 33 ms
4,380 KB
testcase_20 AC 65 ms
4,380 KB
testcase_21 AC 69 ms
4,380 KB
testcase_22 AC 67 ms
4,376 KB
testcase_23 AC 24 ms
4,376 KB
testcase_24 AC 68 ms
4,380 KB
testcase_25 AC 35 ms
4,376 KB
testcase_26 AC 36 ms
4,376 KB
testcase_27 AC 99 ms
4,380 KB
testcase_28 AC 57 ms
4,376 KB
testcase_29 AC 116 ms
4,376 KB
testcase_30 AC 28 ms
4,380 KB
testcase_31 AC 126 ms
4,376 KB
testcase_32 AC 36 ms
4,380 KB
testcase_33 AC 109 ms
4,376 KB
testcase_34 AC 48 ms
4,380 KB
testcase_35 AC 117 ms
4,380 KB
testcase_36 AC 3 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 AC 4 ms
4,376 KB
testcase_44 AC 16 ms
4,376 KB
testcase_45 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr int inf = 1e9 + 10;
constexpr ll INF = (ll)4e18 + 10;
constexpr int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
constexpr int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    int h, w;
    cin >> h >> w;
    string a[h];
    rep(i, h) cin >> a[i];
    int cnt = 0;
    rep(i, h) rep(j, w) {
        if (a[i][j] == '#') cnt++;
    }
    repl(i, -h, h) repl(j, -w, w) {
        if (i == 0 and j == 0) continue;
        int m = 0;
        vector<vector<int>> c(h, vector<int>(w));
        rep(s, h) rep(t, w) {
            if (s + i < 0 or h <= s + i or t + j < 0 or w <= t + j or a[s][t] == '.' or c[s][t])
                continue;
            if (a[s][t] == a[s + i][t + j] and c[s][t] == 0 and c[s + i][t + j] == 0) {
                c[s][t] = c[s + i][t + j] = 1;
                m += 2;
            }
        }
        if (m == cnt) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}
0