結果

問題 No.160 最短経路のうち辞書順最小
ユーザー tailstails
提出日時 2015-03-02 00:01:23
言語 Perl
(5.38.2)
結果
TLE  
実行時間 -
コード長 458 bytes
コンパイル時間 58 ms
コンパイル使用メモリ 5,340 KB
実行使用メモリ 9,760 KB
最終ジャッジ日時 2023-09-06 06:04:41
合計ジャッジ時間 10,809 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,676 KB
testcase_01 AC 2 ms
4,568 KB
testcase_02 AC 2 ms
4,716 KB
testcase_03 AC 3 ms
4,764 KB
testcase_04 AC 1,117 ms
6,392 KB
testcase_05 AC 989 ms
7,888 KB
testcase_06 AC 1,398 ms
9,760 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Name "main::m" used only once: possible typo at Main.pl line 1.
Main.pl syntax OK

ソースコード

diff #

($n,$m,$s,$g)=<>=~/\d+/g;
for(<>){
    ($a,$b,$c)=/\d+/g;
    $c{$a,$b}=$c{$b,$a}=$c;
}
$v[$g]=1;
push@a,$g;
while(@a){
    @a=sort{$v[$a]-$v[$b]}@a;
    $a=pop@a;
    for$b(0..$n-1){
	if($c=$c{$a,$b}){
	    if($v[$b]==0||$v[$b]>$v[$a]+$c) {
		$v[$b]=$v[$a]+$c;
		$p[$b]=$a;
		push@a,$b;
	    }elsif($v[$b]==$v[$a]+$c) {
		$p[$b].=" $a";
		push@a,$b;
	    }
	}
    }
}
print $s;
$a=$s;
do{
    ($a)=sort{$a-$b}$p[$a]=~/\d+/g;
    print" $a";
}while($a!=$g);
0