結果

問題 No.179 塗り分け
ユーザー mencotton
提出日時 2020-11-02 16:06:45
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,645 bytes
コンパイル時間 725 ms
コンパイル使用メモリ 74,520 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-22 06:19:51
合計ジャッジ時間 3,344 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 38 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; i++)cin >> s[i];

    bool ret = false;
    for (int x = 0; x < 50; x++) {
        for (int y = 0; y < 50; y++) {
            if (x == 0 && y == 0)continue;

            vector<string> now = s;
            bool ok = true;
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if (now[i][j] == '#') {
                        if (i + x < h && j + y < w && now[i + x][j + y] == '#') {
                            now[i + x][j + y] = '.';
                        } else {
                            ok = false;
                        }
                    }
                }
            }
            if (ok)ret = true;
        }
    }

    for (int i = 0; i < h; i++) reverse(s[i].begin(), s[i].end());

    for (int x = 0; x < 50; x++) {
        for (int y = 0; y < 50; y++) {
            if (x == 0 && y == 0)continue;

            vector<string> now = s;
            bool ok = true;
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if (now[i][j] == '#') {
                        if (i + x < h && j + y < w && now[i + x][j + y] == '#') {
                            now[i + x][j + y] = '.';
                        } else {
                            ok = false;
                        }
                    }
                }
            }
            if (ok)ret = true;
        }
    }

    cout << (ret ? "YES" : "NO") << endl;
    return 0;
}
0