結果

問題 No.2641 draw X
ユーザー Nzt3Nzt3
提出日時 2024-02-19 22:25:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 2,001 bytes
コンパイル時間 1,999 ms
コンパイル使用メモリ 211,276 KB
実行使用メモリ 32,000 KB
最終ジャッジ日時 2024-02-19 22:25:05
合計ジャッジ時間 4,101 ms
ジャッジサーバーID
(参考情報)
judge11 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 1 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 1 ms
6,676 KB
testcase_08 AC 1 ms
6,676 KB
testcase_09 AC 1 ms
6,676 KB
testcase_10 AC 1 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 1 ms
6,676 KB
testcase_13 AC 1 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 36 ms
32,000 KB
testcase_16 AC 42 ms
32,000 KB
testcase_17 AC 1 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 1 ms
6,676 KB
testcase_20 AC 5 ms
6,676 KB
testcase_21 AC 9 ms
7,680 KB
testcase_22 AC 4 ms
6,676 KB
testcase_23 AC 8 ms
7,040 KB
testcase_24 AC 3 ms
6,676 KB
testcase_25 AC 3 ms
6,676 KB
testcase_26 AC 10 ms
7,936 KB
testcase_27 AC 4 ms
6,676 KB
testcase_28 AC 16 ms
13,440 KB
testcase_29 AC 28 ms
25,856 KB
testcase_30 AC 29 ms
22,016 KB
testcase_31 AC 24 ms
15,744 KB
testcase_32 AC 39 ms
25,856 KB
testcase_33 AC 33 ms
25,728 KB
testcase_34 AC 21 ms
16,256 KB
testcase_35 AC 18 ms
14,592 KB
testcase_36 AC 54 ms
28,928 KB
testcase_37 AC 48 ms
30,464 KB
testcase_38 AC 50 ms
27,520 KB
testcase_39 AC 60 ms
31,488 KB
testcase_40 AC 47 ms
30,080 KB
testcase_41 AC 44 ms
27,648 KB
testcase_42 AC 53 ms
28,672 KB
testcase_43 AC 54 ms
27,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H,W;
  cin>>H>>W;
  vector<string>S(H);
  for(auto &i:S)cin>>i;
  vector dp00(H,vector(W,0)),dp01(H,vector(W,0)),dp10(H,vector(W,0)),dp11(H,vector(W,0));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      int t=0;
      if(i>0&&j>0&&S[i-1][j-1]=='#'){
        t=dp00[i-1][j-1];
      }
      if(S[i][j]=='#'){
        dp00[i][j]=t+1;
      }
    }
  }

  for(int i=0;i<H;i++){
    for(int j=W-1;j>=0;j--){
      int t=0;
      if(i>0&&j+1<W&&S[i-1][j+1]=='#'){
        t=dp01[i-1][j+1];
      }
      if(S[i][j]=='#'){
        dp01[i][j]=t+1;
      }
    }
  }

  for(int i=H-1;i>=0;i--){
    for(int j=0;j<W;j++){
      int t=0;
      if(i+1<H&&j>0&&S[i+1][j-1]=='#'){
        t=dp10[i+1][j-1];
      }
      if(S[i][j]=='#'){
        dp10[i][j]=t+1;
      }
    }
  }

  for(int i=H-1;i>=0;i--){
    for(int j=W-1;j>=0;j--){
      int t=0;
      if(i+1<H&&j+1<W&&S[i+1][j+1]=='#'){
        t=dp11[i+1][j+1];
      }
      if(S[i][j]=='#'){
        dp11[i][j]=t+1;
      }
    }
  }

  vector cnt(H,vector(W,0));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cnt[i][j]=min({dp00[i][j],dp01[i][j],dp10[i][j],dp11[i][j]});

    }
  }
  vector imos0(H+1,vector(W+1,0)),imos1(H+1,vector(W+1,0));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      int t=cnt[i][j]-1;
      if(t>=1){
        imos0[i-t][j-t]+=1;
        imos0[i+t+1][j+t+1]-=1;
        imos1[i-t][j+t]+=1;
        if(j-t-1>=0)imos1[i+t+1][j-t-1]-=1;
      }
    }
  }

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(i-1>=0&&j-1>=0){
        imos0[i][j]+=imos0[i-1][j-1];
      }
    }
    for(int j=W-1;j>=0;j--){
      if(i-1>=0&&j+1<W){
        imos1[i][j]+=imos1[i-1][j+1];
      }
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(S[i][j]=='#'&&imos0[i][j]+imos1[i][j]==0){
        cout<<"No\n";
        return 0;
      }
    }
  }
  cout<<"Yes\n";
}
0