結果

問題 No.179 塗り分け
ユーザー mugen_1337mugen_1337
提出日時 2020-12-14 09:19:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,526 bytes
コンパイル時間 2,258 ms
コンパイル使用メモリ 210,472 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 04:48:08
合計ジャッジ時間 6,491 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define ALL(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}
template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}


signed main(){
    int h,w;cin>>h>>w;
    vector<string> s(h);
    cin>>s;

    {
        int t=0;
        rep(i,h)rep(j,w)t+=(s[i][j]=='#');
        if(!t){
            cout<<"NO"<<endl;
            return 0;
        }
    }

    for(int si=0;si<h;si++)for(int sj=0;sj<w;sj++)if(si or sj){
        vector<vector<int>> c(h,vector<int>(w,0));
        bool f=true;
        rep(i,h)rep(j,w)if(f){
            if(s[i][j]=='.'){
                c[i][j]=3;
                continue;
            }

            if(c[i][j]) continue;
            if(i+si>=h or j+sj>=w){
                f=false;
                break;
            }
            if(s[i+si][j+sj]=='.'){
                f=false;
                break;
            }
            c[i][j]=0;
            c[i+si][j+sj]=1;
        }
        if(f){
            cout<<"YES"<<endl;
            return 0;
        }
    }

    for(int si=0;si<h;si++)for(int sj=0;sj>-w;sj--)if(si or sj){
        vector<vector<int>> c(h,vector<int>(w,0));
        bool f=true;
        rep(i,h)for(int j=w-1;j>=0;j--)if(f){
            if(s[i][j]=='.'){
                c[i][j]=3;
                continue;
            }

            if(c[i][j]) continue;
            if(i+si>=h or j+sj>=w){
                f=false;
                break;
            }
            if(s[i+si][j+sj]=='.'){
                f=false;
                break;
            }
            c[i][j]=0;
            c[i+si][j+sj]=1;
        }
        if(f){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}
0