結果
| 問題 | 
                            No.179 塗り分け
                             | 
                    
| コンテスト | |
| ユーザー | 
                             cureskol
                         | 
                    
| 提出日時 | 2020-04-10 13:44:30 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 71 ms / 3,000 ms | 
| コード長 | 1,161 bytes | 
| コンパイル時間 | 1,721 ms | 
| コンパイル使用メモリ | 170,560 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-07-23 15:13:10 | 
| 合計ジャッジ時間 | 3,561 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 6 | 
| other | AC * 40 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
signed main(){
  int h,w;cin>>h>>w;
  vector<string> s(h),t(h);
  for(int i=0;i<h;i++)cin>>s[i];
  bool f=false;
  for(int i=0;i<h;i++)for(int j=0;j<w;j++)f|=s[i][j]=='#';
  if(!f)fin("NO");
  for(int R=0;R<w;R++){
    for(int D=0;D<h;D++){
      if(!R&&!D)continue;
      bool ok=1;
      for(int i=0;i<h;i++)t[i]=s[i];
      for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
          if(t[i][j]=='#'){
            if(j+R>=w||i+D>=h)ok=0;
            else if(t[i+D][j+R]!='#')ok=0;
            else t[i+D][j+R]='.';
          }
        }
      }
      if(ok)fin("YES");
    }
  }
  for(int i=0;i<h;i++)reverse(s[i].begin(),s[i].end());
  for(int R=0;R<w;R++){
    for(int D=0;D<h;D++){
      if(!R&&!D)continue;
      bool ok=1;
      for(int i=0;i<h;i++)t[i]=s[i];
      for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
          if(t[i][j]=='#'){
            if(j+R>=w||i+D>=h)ok=0;
            else if(t[i+D][j+R]!='#')ok=0;
            else t[i+D][j+R]='.';
          }
        }
      }
      if(ok)fin("YES");
    }
  }
  fin("NO");
}
            
            
            
        
            
cureskol