結果

問題 No.179 塗り分け
ユーザー smiken_61smiken_61
提出日時 2015-10-23 12:42:03
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,393 bytes
コンパイル時間 690 ms
コンパイル使用メモリ 60,272 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-10 12:50:20
合計ジャッジ時間 2,039 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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