結果

問題 No.179 塗り分け
ユーザー kuhaku
提出日時 2025-05-07 16:43:08
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,251 bytes
コンパイル時間 3,276 ms
コンパイル使用メモリ 90,204 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-05-07 16:43:14
合計ジャッジ時間 3,037 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 35 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

// competitive-verifier: PROBLEM https://yukicoder.me/problems/no/0179
#include <iostream>
#include <string>
#include <vector>
int main(void) {
    int h, w;
    std::cin >> h >> w;
    std::vector<std::string> b(h);
    for (auto &s : b) std::cin >> s;
    int c = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            c += b[i][j] == '#';
        }
    }
    if (c == 0) {
        std::cout << "NO\n";
        return 0;
    }
    bool ans = false;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (i == 0 && j == 0)
                continue;
            bool f = true;
            std::vector dp(h, std::vector(w, -1));
            for (int x = 0; x < h; ++x) {
                for (int y = 0; y < w; ++y) {
                    if (b[x][y] == '#') {
                        if (dp[x][y] == 1)
                            continue;
                        if (i + x < h && j + y < w && b[i + x][j + y] == '#')
                            dp[i + x][j + y] = 1;
                        else
                            f = false;
                    }
                }
            }
            ans |= f;
        }
    }
    std::cout << (ans ? "YES\n" : "NO\n");
    return 0;
}
0