結果
問題 |
No.179 塗り分け
|
ユーザー |
![]() |
提出日時 | 2017-05-03 06:35:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 32 ms / 3,000 ms |
コード長 | 844 bytes |
コンパイル時間 | 1,599 ms |
コンパイル使用メモリ | 168,848 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-23 14:42:35 |
合計ジャッジ時間 | 3,276 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 40 |
ソースコード
#include <bits/stdc++.h> #define REP(i,n,N) for(int i=(n);i<(int)N;i++) #define p(s) cout<<(s)<<endl #define ck(n,a,b) ((a)<=(n)&&(n)<(b)) using namespace std; int main(){ int H,W; cin>>H>>W; string s[51]; bool ok=false; REP(i,0,H) { cin>>s[i]; if(s[i].find('#')<s[i].size()) ok=true; } string ans="NO"; if(ok) REP(dy,-H+1,H){ REP(dx,-W+1,W){ if(dy==0&&dx==0) continue; string tmps[51]; REP(i,0,H) tmps[i]=s[i]; bool flag=true; REP(i,0,H){ REP(j,0,W){ if(tmps[i][j]=='.') continue; int nx=j+dx; int ny=i+dy; if(!ck(ny,0,H)||!ck(nx,0,W)) { flag=false; break; } if(tmps[ny][nx]=='#'){//can move tmps[ny][nx]='.';//used }else{ flag=false; break; } } if(!flag) break; } if(flag) { ans="YES"; } } } p(ans); return 0; }