結果

問題 No.2641 draw X
ユーザー otoshigootoshigo
提出日時 2024-02-20 10:17:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 2,034 bytes
コンパイル時間 1,282 ms
コンパイル使用メモリ 85,584 KB
実行使用メモリ 28,160 KB
最終ジャッジ日時 2024-02-20 10:17:36
合計ジャッジ時間 3,943 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 1 ms
6,676 KB
testcase_15 AC 26 ms
28,160 KB
testcase_16 AC 50 ms
28,160 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 5 ms
6,676 KB
testcase_21 AC 8 ms
7,168 KB
testcase_22 AC 5 ms
6,676 KB
testcase_23 AC 7 ms
6,676 KB
testcase_24 AC 3 ms
6,676 KB
testcase_25 AC 4 ms
6,676 KB
testcase_26 AC 10 ms
7,424 KB
testcase_27 AC 3 ms
6,676 KB
testcase_28 AC 13 ms
12,160 KB
testcase_29 AC 22 ms
22,912 KB
testcase_30 AC 23 ms
19,584 KB
testcase_31 AC 24 ms
14,208 KB
testcase_32 AC 32 ms
22,912 KB
testcase_33 AC 38 ms
22,784 KB
testcase_34 AC 23 ms
14,720 KB
testcase_35 AC 19 ms
13,184 KB
testcase_36 AC 41 ms
25,472 KB
testcase_37 AC 50 ms
26,880 KB
testcase_38 AC 41 ms
24,320 KB
testcase_39 AC 52 ms
27,776 KB
testcase_40 AC 58 ms
26,496 KB
testcase_41 AC 36 ms
24,320 KB
testcase_42 AC 48 ms
25,344 KB
testcase_43 AC 50 ms
24,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
using ll=long long;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H,W;
    cin>>H>>W;
    vector<string>S(H);
    for(int i=0;i<H;i++)cin>>S[i];
    vector V(4,vector(H,vector<int>(W)));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(S[i][j]=='#'){
                V[0][i][j]=(i-1>=0&&j-1>=0?V[0][i-1][j-1]:0)+1;
                V[1][i][j]=(i-1>=0&&j+1<W?V[1][i-1][j+1]:0)+1;
            }
        }
    }
    for(int i=H-1;i>=0;i--){
        for(int j=0;j<W;j++){
            if(S[i][j]=='#'){
                V[2][i][j]=(i+1<H&&j+1<W?V[2][i+1][j+1]:0)+1;
                V[3][i][j]=(i+1<H&&j-1>=0?V[3][i+1][j-1]:0)+1;
            }
        }
    }
    vector X(H+1,vector<int>(W+1)),Y(H+1,vector<int>(W+1));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(S[i][j]=='#'){
                int l=1<<30;
                for(int k=0;k<4;k++){
                    chmin(l,V[k][i][j]);
                }
                l--;
                if(l>0){
                    X[i-l][j-l]++;
                    X[i+l+1][j+l+1]--;
                    Y[i-l][j+l+1]++;
                    Y[i+l+1][j-l]--;
                }
            }
        }
    }
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            X[i][j]+=X[i-1][j-1];
        }
    }
    for(int i=1;i<=H;i++){
        for(int j=0;j<W;j++){
            Y[i][j]+=Y[i-1][j+1];
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int sum=X[i][j]+Y[i][j+1];
            if((sum>0&&S[i][j]=='.')||(sum==0&&S[i][j]=='#')){
                cout<<"No"<<"\n";
                return 0;
            }
        }
    }
    cout<<"Yes"<<"\n";
}
0