結果

問題 No.402 最も海から遠い場所
ユーザー tailstails
提出日時 2016-07-22 23:08:49
言語 Perl
(5.38.2)
結果
TLE  
実行時間 -
コード長 1,137 bytes
コンパイル時間 669 ms
コンパイル使用メモリ 6,144 KB
実行使用メモリ 157,440 KB
最終ジャッジ日時 2024-04-24 05:57:45
合計ジャッジ時間 10,152 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
11,520 KB
testcase_01 AC 7 ms
6,016 KB
testcase_02 AC 53 ms
7,808 KB
testcase_03 AC 7 ms
5,888 KB
testcase_04 AC 7 ms
6,144 KB
testcase_05 AC 8 ms
6,144 KB
testcase_06 AC 6 ms
6,016 KB
testcase_07 AC 7 ms
5,888 KB
testcase_08 AC 6 ms
6,016 KB
testcase_09 AC 7 ms
6,144 KB
testcase_10 AC 8 ms
6,144 KB
testcase_11 AC 25 ms
6,784 KB
testcase_12 AC 14 ms
6,272 KB
testcase_13 AC 587 ms
24,576 KB
testcase_14 AC 212 ms
13,184 KB
testcase_15 TLE -
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

($h,$w,$/)=glob<>;$s=<>;

for$y(0..$h-1){
	for$x(0..$w-1){
		$a0{$x,$y}=1e4;
		for($x-1..$x+1){
			$a0{$x,$y}=$a0{$_,$y-1} if $a0{$x,$y}>$a0{$_,$y-1};
		}
		$a0{$x,$y}+=1;
		$a0{$x,$y}=0 if substr($s,$y*($w+1)+$x,1) eq '.';
		$b0=$a0{$x,$y} if $b0<$a0{$x,$y};
	}
}

for$y(reverse 0..$h-1){
	for$x(0..$w-1){
		$a1{$x,$y}=1e4;
		for($x-1..$x+1){
			$a1{$x,$y}=$a1{$_,$y+1} if $a1{$x,$y}>$a1{$_,$y+1};
		}
		$a1{$x,$y}+=1;
		$a1{$x,$y}=0 if substr($s,$y*($w+1)+$x,1) eq '.';
		$b1=$a1{$x,$y} if $b1<$a1{$x,$y};
	}
}

for$x(0..$w-1){
	for$y(0..$h-1){
		$a2{$x,$y}=1e4;
		for($y-1..$y+1){
			$a2{$x,$y}=$a2{$x-1,$_} if $a2{$x,$y}>$a2{$x-1,$_};
		}
		$a2{$x,$y}+=1;
		$a2{$x,$y}=0 if substr($s,$y*($w+1)+$x,1) eq '.';
		$b2=$a2{$x,$y} if $b2<$a2{$x,$y};
	}
}

for$x(reverse 0..$w-1){
	for$y(0..$h-1){
		$a3{$x,$y}=1e4;
		for($y-1..$y+1){
			$a3{$x,$y}=$a3{$x+1,$_} if $a3{$x,$y}>$a3{$x+1,$_};
		}
		$a3{$x,$y}+=1;
		$a3{$x,$y}=0 if substr($s,$y*($w+1)+$x,1) eq '.';
		$b3=$a3{$x,$y} if $b3<$a3{$x,$y};
	}
}

for$y(0..$h-1){
	for$x(0..$w-1){
		$c=1e4;
		for(a0,a1,a2,a3){
			$c=$$_{$x,$y} if $c>$$_{$x,$y};
		}
		$b=$c if $b<$c;
	}
}

print$b;
0