結果

問題 No.179 塗り分け
ユーザー Zettsu TatsuyaZettsu Tatsuya
提出日時 2023-11-29 20:33:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,278 bytes
コンパイル時間 2,287 ms
コンパイル使用メモリ 204,396 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-11-29 20:33:27
合計ジャッジ時間 3,856 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>

namespace {
using ModInt [[maybe_unused]] = atcoder::modint998244353;
using Num [[maybe_unused]] = long long int;
using Vec [[maybe_unused]] = std::vector<Num>;
using Set [[maybe_unused]] = std::set<Num>;
using Mset [[maybe_unused]] = std::multiset<Num>;
using Edges [[maybe_unused]] = std::vector<std::vector<Num>>;

template<typename T>
using Q [[maybe_unused]] = std::queue<T>;

template<typename T>
using PQ [[maybe_unused]] = std::priority_queue<T, std::vector<T>, std::greater<T>>;
}

using Grid = std::array<std::array<Num, 50>, 50>;

void solve(std::istream& is, std::ostream& os) {
    Num h {0};
    Num w {0};
    is >> h >> w;

    Grid base;
    for(Num y{0}; y<h; ++y) {
        std::string s;
        is >> s;
        for(Num x{0}; x<w; ++x) {
            base[y][x] = s.at(x) == '#';
        }
    }

    for(Num dy{0}; dy<h; ++dy) {
        for(Num dx{0}; dx<w; ++dx) {
            if ((dy == 0) && (dx == 0)) {
                continue;
            }

            auto g = base;
            bool failed {false};
            for(Num y{0}; !failed && (y<h); ++y) {
                const auto ty = dy + y;

                for(Num x{0}; !failed && (x<w); ++x) {
                    const auto tx = dx + x;

                    if (g[y][x] == 0) {
                        continue;
                    }

                    if (g[y][x] == 1) {
                        if ((ty >= h) || (tx >= w) || (g[ty][tx] != 1)) {
                            failed = true;
                            break;
                        }
                        g[y][x] = 2;
                        g[ty][tx] = 3;
                    }
                }
            }

            Num ct2 {0};
            Num ct3 {0};
            for(Num y{0}; !failed && (y<h); ++y) {
                for(Num x{0}; !failed && (x<w); ++x) {
                    failed |= (g[y][x] == 1);
                    ct2 |= (g[y][x] == 2);
                    ct3 |= (g[y][x] == 3);
                }
            }

            if (!failed && (ct2 > 0) && (ct3 > 0)) {
                os << "YES\n";
                return;
            }
        }
    }

    os << "NO\n";
    return;
}

int main(void) {
    solve(std::cin, std::cout);
    return 0;
}
0