結果
問題 | No.179 塗り分け |
ユーザー |
![]() |
提出日時 | 2016-08-23 09:00:05 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 52 ms / 3,000 ms |
コード長 | 818 bytes |
コンパイル時間 | 1,377 ms |
コンパイル使用メモリ | 164,052 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-23 14:38:28 |
合計ジャッジ時間 | 3,156 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 40 |
ソースコード
#include<bits/stdc++.h> using namespace std; // not.. bool F(vector<string> s){ int h=s.size(); int w=s[0].size(); if(s==vector<string>(h,string(w,'.'))) return false; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ if(i==0&&j==0) continue; bool ok=true; vector<string> t=s; for(int y=0;y<h;y++){ for(int x=0;x<w;x++){ int y2=y+i; int x2=x+j; char c='.'; if(y2<h&&x2<w) c=t[y2][x2]; if(t[y][x]=='#'){ if(c=='.') ok=false; else if(y2<h&&x2<w) t[y2][x2]='.'; } } } if(ok) return true; } } return false; } int main(){ int h,w; cin >> h >> w; vector<string> s(h); for(int i=0;i<h;i++) cin >> s[i]; vector<string> t=s; reverse(t.begin(),t.end()); if(F(s) || F(t)) cout << "YES" << endl; else cout << "NO" << endl; return 0; }