結果

問題 No.179 塗り分け
ユーザー smiken_61smiken_61
提出日時 2015-10-23 12:42:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 7 ms / 3,000 ms
コード長 1,395 bytes
コンパイル時間 533 ms
コンパイル使用メモリ 61,852 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-30 20:44:58
合計ジャッジ時間 2,208 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
using namespace std;


int za(int ta, int yo,int i, int j){
if(-1<i && -1<j && ta>i && yo>j) return (i*yo)+j;
else return -1;
}
pair<int,int> mo(int ta,int yo,int m){
return make_pair(m/yo,m%yo);
}




int main() {
int ta,yo;
string s;
int ma[52][52]={0};
int re[2704]={0};
int minz=10000;
cin>>ta>>yo;
for(int i=0;i<ta;i++){

cin>>s;
for(int j=0;j<yo;j++){
if(s[j]=='.'){
ma[i][j]=0;
re[za(ta,yo,i,j)]=0;
}
else if(s[j]=='#'){
ma[i][j]=1;
re[za(ta,yo,i,j)]=1;
if(za(ta,yo,i,j)<minz) minz=za(ta,yo,i,j);

}

}
}
int ans=0,l;
//cout<<minz<<endl;
if(minz==10000) ans=0;
else{
	for(int k=1;k<ta*yo-minz;k++){
		//if(k>=ta*yo-minz) break;
		if(ans==0&&re[minz+k]==1){
		int co[2704]={0};
		for(int i=0;i<2704;i++) co[i]=re[i];
		co[minz+k]=2;
		l=minz+1;
		int dx=mo(ta,yo,minz+k).first-mo(ta,yo,minz).first;
		int dy=mo(ta,yo,minz+k).second-mo(ta,yo,minz).second;
		while(l<ta*yo){
			if(co[l]==1)	{
				if(za(ta,yo,dx+mo(ta,yo,l).first,dy+mo(ta,yo,l).second)<0) l=ta*yo+1;
				else if(co[za(ta,yo,dx+mo(ta,yo,l).first,dy+mo(ta,yo,l).second)]!=1) l=ta*yo+1;
				else co[za(ta,yo,dx+mo(ta,yo,l).first,dy+mo(ta,yo,l).second)]=2;
			}
			l=l+1;
		}
		if(l==ta*yo) ans=1;
	//	cout<<k<<"  ";
	//	for(int i=0;i<9;i++) cout<<co[i];
	//	cout<<endl;
		}
		
	}
}
if(ans==0) cout<<"NO"<<endl;
else cout<<"YES"<<endl;


return 0;
}
0