結果

問題 No.179 塗り分け
ユーザー dnish
提出日時 2017-05-03 06:26:38
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 771 bytes
コンパイル時間 1,549 ms
コンパイル使用メモリ 169,164 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-03 03:41:44
合計ジャッジ時間 3,117 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 39 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#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];
	REP(i,0,H) cin>>s[i];
	string ans="NO";
	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;
}
0