結果

問題 No.179 塗り分け
ユーザー e-mon
提出日時 2015-04-06 01:25:52
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 12 ms / 3,000 ms
コード長 1,781 bytes
コンパイル時間 877 ms
コンパイル使用メモリ 87,440 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-23 14:27:18
合計ジャッジ時間 1,905 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

int main(){
    int H,W;
    cin >> H >> W;
    char M[H][W];
    int used[H][W];
    int count = 0;

    FOR(i,0,H){
        FOR(j,0,W){
            cin >> M[i][j];
            if(M[i][j] == '#') count++;
         }
    }
    if(count == 0){
        cout << "NO" << endl;
        return 0;
      }

    REP(i,H){
        FOR(j,-W,W){
            if(i == 0 and j == 0) continue;
            int count = 0;
            memset(used,0,H*W*sizeof(int));
            REP(k,H){
                int l;
                for(l=0;l<W;l++){
                    if(M[k][l] == '#' and used[k][l] == 0){
                        if(0 <= k + i and k+i< H and 0 <= l+j and l+j < W and  M[k+i][l+j] == '#' and used[k+i][l+j] == 0){
                            used[k][l] = 1;
                            used[k+i][l+j] = 1;
                        }else{
                            break;
                        }
                    }
                }
                if(l==W) count++;
            }
            if(count == H){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;

    return 0;
}
0