結果

問題 No.179 塗り分け
ユーザー kongarishisyamokongarishisyamo
提出日時 2016-04-17 00:19:39
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 90 ms / 3,000 ms
コード長 828 bytes
コンパイル時間 372 ms
コンパイル使用メモリ 54,644 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-30 20:48:08
合計ジャッジ時間 2,833 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<string>

using namespace std;

#define HMAX 50

int main(){

	int H,W;
	string s[HMAX];

	cin>>H>>W;
	for(int i=0;i<H;i++) cin>>s[i];

	bool f=false;
	for(int i=0;i<H&&!f;i++){
		for(int j=0;j<W&&!f;j++){
			if(s[i][j]=='#') f=true;
		}
	}
	if(!f){
		cout<<"NO"<<endl;
		return 0;
	}
	for(int i=-H+1;i<H;i++){
		for(int j=0;j<W;j++){
			if(i==0&&j==0) continue;
			string stmp[HMAX];
			for(int k=0;k<H;k++) stmp[k]=s[k];
			f=true;
			for(int k=0;k<H;k++){
				for(int l=0;l<W;l++){
					if(stmp[k][l]=='#'){
						if(!(k+i<0||k+i>=H||l+j>=W||stmp[k+i][l+j]!='#')) stmp[k][l]='.',stmp[k+i][l+j]='.';
					}
				}
			}
			for(int k=0;k<H&&f;k++){
				for(int l=0;l<W&&f;l++){
					if(stmp[k][l]=='#') f=false;
				}
			}
			if(f){
				cout<<"YES"<<endl;
				return 0;
			}
		}
	}
	cout<<"NO"<<endl;
}
0