結果

問題 No.179 塗り分け
ユーザー honakehonake
提出日時 2016-10-19 22:28:12
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,876 bytes
コンパイル時間 665 ms
コンパイル使用メモリ 62,116 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 06:11:35
合計ジャッジ時間 2,695 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    string s;
    bool blank = false;
    bool flag = false;
    bool ans = false;
    int a[100][100];
    
    rep(i, 100) {
        rep(j, 100) { a[i][j] = -1; }
    }
    
    rep(i, h) {
        cin >> s;
        rep(j, w) {
            if(s[j] == '#'){
                a[i][j] = 1;
                blank = true;
            }else{
                a[i][j] = 0;
            }
        }
    }
    
    for(int ud=-50; ud<=50; ud++){
        for(int lr=-50; lr<=50; lr++){
            if(ud==0 and lr==0){
                continue;
            }
            int done[100][100];
            rep(i, 100) {
                rep(j, 100) { done[i][j] = 0; }
            }
            rep(i, h) {
                rep(j, w) {
                    if(done[i][j] == 1){
                        continue;
                    }
                    if (a[i][j] == 1) {
                        if(i+ud<0 or i+ud>=h or j+lr<0 or j+lr>=w){
                            flag = true;
                            break;
                        }
                        if (a[i + ud][j + lr] != 1) {
                            flag = true;
                            break;
                        }
                        done[i+ud][j+lr] = 1;
                    }
                }
                if (flag) {
                    break;
                }
            }
            if (!flag) {
                ans = true;
                break;
            } else {
                flag = false;
            }
        }
    }
    
    if(blank){
        cout << "NO" << endl;
    }else{
        cout << ((ans) ? "YES" : "NO") << endl;
    }
    return 0;
}
0