結果

問題 No.179 塗り分け
ユーザー sugarrrsugarrr
提出日時 2018-03-03 15:42:59
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 13 ms / 3,000 ms
コード長 1,444 bytes
コンパイル時間 1,341 ms
コンパイル使用メモリ 74,272 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 20:58:22
合計ジャッジ時間 2,257 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/
#define rep(i,l,r) for(int i=l;i<=r;i++)
const double EPS=1E-8;

////////////////////////////////////////
int h,w;
char p[55][55+1];
bool flag=false;
void solve(int x,int y){
    char m[h][w+1];
    rep(i,0,h-1)rep(j,0,w-1)m[i][j]=p[i][j];
    rep(i,0,h-1)rep(j,0,w-1){
        if(m[i][j]=='#'){
            m[i][j]='.';
            if(i+x>=h||j+y>=w||i+x<0||j+y<0)return;
            if(m[i+x][j+y]=='.')return;
            m[i+x][j+y]='.';
        }
    }
    bool flg=true;
    rep(i,0,h-1)rep(j,0,w-1)if(m[i][j]!='.')flg=false;
    if(flg){
        cout<<"YES"; /* printf(" %d %d ",x,y);*/
    flag=true;
    }
}



int main(){
    cin>>h>>w;
    rep(i,0,h-1)cin>>p[i];
    bool a=false;
    rep(i,0,h-1){
        rep(j,0,w-1){
            if(p[i][j]=='#')a=true;
        }
    }
    if(!a){
        cout<<"NO";return 0;
    }
    rep(i,0,h-1){
        rep(j,-w+1,w-1){
            if(!flag)solve(i,j);
        }
    }
    if(!flag)cout<<"NO";
    
    return 0;
}
0