結果

問題 No.86 TVザッピング(2)
ユーザー cielciel
提出日時 2015-04-24 17:11:07
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 744 bytes
コンパイル時間 634 ms
コンパイル使用メモリ 60,972 KB
実行使用メモリ 7,460 KB
最終ジャッジ日時 2023-09-18 08:55:40
合計ジャッジ時間 6,948 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
using namespace std;
typedef struct{
	int x;
	int y;
}dir;
const dir D[]={
	{0,-1},
	{-1,0},
	{0,1},
	{1,0},
};
int main(){
	int H,W,path=0;
	cin>>H>>W;
	vector<string>v(H);
	for(int i=0;i<H;i++){
		cin>>v[i];
		for(int j=0;j<W;j++)path+=v[i][j]=='.';
	}
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)if(v[i][j]=='.'){
		for(int _d=0;_d<4;_d++){
			int x=j,y=i,p=0;
			for(int d=_d,fail=0;fail<2;){
				int nx=x+D[d].x,ny=y+D[d].y;
				if(0<=nx&&nx<W && 0<=ny&&ny<H && v[ny][nx]=='.'){
					x=nx,y=ny;
					fail=0,p++;
					if(x==j&&y==i)break;
				}else{
					fail++,d=(d+1)%4;
				}
			}
			if(p==path&&x==j&&y==i){
				puts("YES");
				return 0;
			}
		}
	}
	puts("NO");
}
0