結果

問題 No.86 TVザッピング(2)
ユーザー cielciel
提出日時 2015-04-24 17:02:38
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 751 bytes
コンパイル時間 448 ms
コンパイル使用メモリ 60,456 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-18 08:52:31
合計ジャッジ時間 1,825 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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&&p<path;d=(d+1)%4){
				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++;
				}
			}
			if(p==path&&x==j&&y==i){
				puts("YES");
				return 0;
			}
		}
	}
	puts("NO");
}
0