結果

問題 No.179 塗り分け
ユーザー honakehonake
提出日時 2016-10-19 22:31:03
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 60 ms / 3,000 ms
コード長 1,881 bytes
コンパイル時間 466 ms
コンパイル使用メモリ 63,764 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-30 20:51:37
合計ジャッジ時間 4,281 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
4,376 KB
testcase_01 AC 48 ms
4,380 KB
testcase_02 AC 49 ms
4,380 KB
testcase_03 AC 50 ms
4,376 KB
testcase_04 AC 48 ms
4,380 KB
testcase_05 AC 48 ms
4,380 KB
testcase_06 AC 48 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 49 ms
4,380 KB
testcase_09 AC 48 ms
4,380 KB
testcase_10 AC 48 ms
4,380 KB
testcase_11 AC 47 ms
4,380 KB
testcase_12 AC 49 ms
4,376 KB
testcase_13 AC 48 ms
4,380 KB
testcase_14 AC 49 ms
4,380 KB
testcase_15 AC 49 ms
4,380 KB
testcase_16 AC 48 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 49 ms
4,376 KB
testcase_19 AC 48 ms
4,380 KB
testcase_20 AC 49 ms
4,376 KB
testcase_21 AC 52 ms
4,376 KB
testcase_22 AC 60 ms
4,376 KB
testcase_23 AC 48 ms
4,380 KB
testcase_24 AC 49 ms
4,376 KB
testcase_25 AC 49 ms
4,376 KB
testcase_26 AC 48 ms
4,380 KB
testcase_27 AC 48 ms
4,376 KB
testcase_28 AC 48 ms
4,380 KB
testcase_29 AC 49 ms
4,376 KB
testcase_30 AC 48 ms
4,376 KB
testcase_31 AC 48 ms
4,376 KB
testcase_32 AC 48 ms
4,376 KB
testcase_33 AC 48 ms
4,376 KB
testcase_34 AC 48 ms
4,376 KB
testcase_35 AC 49 ms
4,380 KB
testcase_36 AC 49 ms
4,380 KB
testcase_37 AC 48 ms
4,376 KB
testcase_38 AC 48 ms
4,380 KB
testcase_39 AC 49 ms
4,376 KB
testcase_40 AC 48 ms
4,376 KB
testcase_41 AC 48 ms
4,380 KB
testcase_42 AC 48 ms
4,376 KB
testcase_43 AC 48 ms
4,384 KB
testcase_44 AC 48 ms
4,380 KB
testcase_45 AC 49 ms
4,380 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;
            }
        }
    }
    
    if(!blank){
        cout << "NO" << endl;
        return 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;
            }
        }
    }

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