結果

問題 No.157 2つの空洞
ユーザー tailstails
提出日時 2015-02-27 00:08:00
言語 Perl
(5.38.2)
結果
WA  
実行時間 -
コード長 856 bytes
コンパイル時間 188 ms
コンパイル使用メモリ 5,336 KB
実行使用メモリ 4,960 KB
最終ジャッジ日時 2023-09-06 02:58:56
合計ジャッジ時間 1,184 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,604 KB
testcase_01 AC 3 ms
4,604 KB
testcase_02 AC 3 ms
4,580 KB
testcase_03 WA -
testcase_04 AC 3 ms
4,592 KB
testcase_05 WA -
testcase_06 AC 5 ms
4,852 KB
testcase_07 AC 3 ms
4,784 KB
testcase_08 AC 3 ms
4,696 KB
testcase_09 AC 4 ms
4,868 KB
testcase_10 AC 3 ms
4,696 KB
testcase_11 WA -
testcase_12 AC 8 ms
4,748 KB
testcase_13 AC 8 ms
4,756 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 7 ms
4,644 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 17 ms
4,916 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

($w,$h)=<>=~/\d+/g;
$/=\1;
for$y(1..$h){
    for$x(1..$w+1){
	$f{$x,$y}=<>;
    }
}
l1:{
    for$y(1..$h){
	for$x(1..$w){
	    if($f{$x,$y}eq'.'){
		$f{$x,$y}=A;
		last l1;
	    }
	}
    }
}
for$y(1..$h){
    for$x(1..$w){
	if($f{$x,$y}eq'.'){
	    if($f{$x-1,$y}eq A || $f{$x+1,$y}eq A || $f{$x,$y-1}eq A || $f{$x,$y+1}eq A ){
		$f{$x,$y}=A;
	    }
	}
    }
}
for$l(0..99){
    for$y(1..$h){
	for$x(1..$w){
	    if($f{$x,$y}eq 'A'){
		if($f{$x-1,$y}eq '.'|| $f{$x+1,$y}eq '.' || $f{$x,$y-1}eq '.' || $f{$x,$y+1}eq '.' ){
		    print $l;
		    exit;
		}
		if($f{$x-1,$y}eq'#'){
		    $f{$x-1,$y}=B;
		}
		if($f{$x+1,$y}eq'#'){
		    $f{$x+1,$y}=B;
		}
		if($f{$x,$y-1}eq'#'){
		    $f{$x,$y-1}=B;
		}
		if($f{$x,$y+1}eq'#'){
		    $f{$x,$y+1}=B;
		}
	    }
	}
    }
    for$y(1..$h){
	for$x(1..$w){
	    if($f{$x,$y}eq B){
		$f{$x,$y}=A;
	    }
	}
    }
}
0