結果

問題 No.17 2つの地点に泊まりたい
ユーザー %20%20
提出日時 2017-07-18 01:00:41
言語 Perl
(5.38.2)
結果
AC  
実行時間 59 ms / 5,000 ms
コード長 442 bytes
コンパイル時間 24 ms
コンパイル使用メモリ 6,688 KB
実行使用メモリ 6,016 KB
最終ジャッジ日時 2024-04-23 02:20:36
合計ジャッジ時間 1,408 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,504 KB
testcase_01 AC 3 ms
5,632 KB
testcase_02 AC 4 ms
5,504 KB
testcase_03 AC 57 ms
5,760 KB
testcase_04 AC 8 ms
5,504 KB
testcase_05 AC 34 ms
5,888 KB
testcase_06 AC 21 ms
5,888 KB
testcase_07 AC 16 ms
5,760 KB
testcase_08 AC 59 ms
6,016 KB
testcase_09 AC 59 ms
6,016 KB
testcase_10 AC 47 ms
5,760 KB
testcase_11 AC 57 ms
5,760 KB
testcase_12 AC 3 ms
5,632 KB
testcase_13 AC 3 ms
5,632 KB
testcase_14 AC 3 ms
5,504 KB
testcase_15 AC 3 ms
5,632 KB
testcase_16 AC 3 ms
5,504 KB
testcase_17 AC 10 ms
5,504 KB
testcase_18 AC 45 ms
5,632 KB
testcase_19 AC 40 ms
5,632 KB
testcase_20 AC 8 ms
5,504 KB
testcase_21 AC 4 ms
5,632 KB
testcase_22 AC 52 ms
5,888 KB
testcase_23 AC 33 ms
5,888 KB
testcase_24 AC 41 ms
5,888 KB
testcase_25 AC 4 ms
5,632 KB
testcase_26 AC 49 ms
5,888 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Unquoted string "inf" may clash with future reserved word at Main.pl line 6.
Unquoted string "inf" may clash with future reserved word at Main.pl line 22.
Main.pl syntax OK

ソースコード

diff #

sub min{$_[$_[1]<$_[0]]}
$N=<>;
$S[$_]=<>for 0..$N-1;
for$i(0..$N-1){
	for$j(0..$N-1){
		$w[$i][$j]=inf;
	}
	$w[$i][$i]=0;
}
<>;
/ .* /,$w[$`][$&]=$w[$&][$`]=$' for<>;
for$m(0..$N-1){
	for$i(0..$N-1){
		for$j(0..$N-1){
			$w[$i][$j]=min(
				$w[$i][$j],
				$w[$i][$m]+$w[$m][$j]
			)
		}
	}
}
$z=inf;
for$x(1..$N-2){
	for$y(1..$N-2){
		if($x!=$y){
			$z=min(
				$z,
				$S[$x]+$S[$y]+$w[0][$x]+$w[$x][$y]+$w[$y][$N-1]
			)
		}
	}
}
print$z
0