結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 AC 2 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 6 ms
4,376 KB
testcase_16 AC 6 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,384 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
4,376 KB
testcase_24 WA -
testcase_25 AC 2 ms
4,376 KB
testcase_26 WA -
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
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++;
				}else{
					fail++;
				}
			}
			if(p==path&&x==j&&y==i){
				puts("YES");
				return 0;
			}
		}
	}
	puts("NO");
}
0