結果

問題 No.179 塗り分け
ユーザー dnishdnish
提出日時 2017-05-03 06:35:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 3,000 ms
コード長 844 bytes
コンパイル時間 1,548 ms
コンパイル使用メモリ 166,576 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-30 20:54:29
合計ジャッジ時間 3,699 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 5 ms
4,376 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 21 ms
4,380 KB
testcase_09 AC 21 ms
4,380 KB
testcase_10 AC 22 ms
4,376 KB
testcase_11 AC 19 ms
4,380 KB
testcase_12 AC 19 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 21 ms
4,380 KB
testcase_19 AC 20 ms
4,380 KB
testcase_20 AC 20 ms
4,376 KB
testcase_21 AC 23 ms
4,380 KB
testcase_22 AC 29 ms
4,380 KB
testcase_23 AC 21 ms
4,376 KB
testcase_24 AC 22 ms
4,376 KB
testcase_25 AC 22 ms
4,376 KB
testcase_26 AC 21 ms
4,380 KB
testcase_27 AC 21 ms
4,376 KB
testcase_28 AC 21 ms
4,384 KB
testcase_29 AC 21 ms
4,380 KB
testcase_30 AC 21 ms
4,380 KB
testcase_31 AC 21 ms
4,376 KB
testcase_32 AC 21 ms
4,376 KB
testcase_33 AC 21 ms
4,376 KB
testcase_34 AC 21 ms
4,380 KB
testcase_35 AC 21 ms
4,376 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 1 ms
4,380 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 5 ms
4,376 KB
testcase_45 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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];
	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;
}
0