結果

問題 No.157 2つの空洞
ユーザー tailstails
提出日時 2015-02-27 00:10:57
言語 Perl
(5.38.2)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 870 bytes
コンパイル時間 49 ms
コンパイル使用メモリ 5,336 KB
実行使用メモリ 4,912 KB
最終ジャッジ日時 2023-09-06 02:59:11
合計ジャッジ時間 1,164 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,556 KB
testcase_01 AC 4 ms
4,584 KB
testcase_02 AC 4 ms
4,700 KB
testcase_03 AC 4 ms
4,708 KB
testcase_04 AC 5 ms
4,648 KB
testcase_05 AC 5 ms
4,656 KB
testcase_06 AC 9 ms
4,588 KB
testcase_07 AC 4 ms
4,648 KB
testcase_08 AC 4 ms
4,568 KB
testcase_09 AC 6 ms
4,656 KB
testcase_10 AC 5 ms
4,584 KB
testcase_11 AC 10 ms
4,732 KB
testcase_12 AC 14 ms
4,880 KB
testcase_13 AC 15 ms
4,888 KB
testcase_14 AC 13 ms
4,816 KB
testcase_15 AC 16 ms
4,772 KB
testcase_16 AC 18 ms
4,656 KB
testcase_17 AC 14 ms
4,912 KB
testcase_18 AC 20 ms
4,800 KB
testcase_19 AC 26 ms
4,912 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(0..99){
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