結果

問題 No.160 最短経路のうち辞書順最小
ユーザー tailstails
提出日時 2015-03-02 01:28:48
言語 Perl
(5.38.2)
結果
RE  
実行時間 -
コード長 459 bytes
コンパイル時間 51 ms
コンパイル使用メモリ 5,328 KB
実行使用メモリ 13,480 KB
最終ジャッジ日時 2023-09-06 06:15:05
合計ジャッジ時間 2,458 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,628 KB
testcase_01 AC 3 ms
4,844 KB
testcase_02 AC 3 ms
4,684 KB
testcase_03 AC 3 ms
4,808 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 25 ms
5,336 KB
testcase_08 AC 34 ms
5,524 KB
testcase_09 AC 32 ms
5,524 KB
testcase_10 AC 31 ms
5,748 KB
testcase_11 AC 36 ms
5,856 KB
testcase_12 AC 38 ms
5,568 KB
testcase_13 AC 30 ms
5,400 KB
testcase_14 AC 27 ms
5,608 KB
testcase_15 AC 26 ms
5,484 KB
testcase_16 AC 41 ms
5,332 KB
testcase_17 AC 29 ms
5,620 KB
testcase_18 AC 34 ms
5,428 KB
testcase_19 AC 43 ms
5,636 KB
testcase_20 AC 50 ms
5,564 KB
testcase_21 AC 23 ms
5,364 KB
testcase_22 AC 26 ms
5,332 KB
testcase_23 AC 38 ms
5,692 KB
testcase_24 AC 40 ms
5,944 KB
testcase_25 AC 30 ms
5,444 KB
testcase_26 AC 31 ms
5,416 KB
testcase_27 AC 14 ms
5,060 KB
testcase_28 AC 114 ms
13,480 KB
testcase_29 AC 12 ms
4,952 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Name "main::m" used only once: possible typo at Main.pl line 1.
Name "main::time" used only once: possible typo at Main.pl line 11.
Main.pl syntax OK

ソースコード

diff #

($n,$m,$s,$g)=<>=~/\d+/g;
for(<>){
    ($a,$b,$c)=/\d+/g;
    $c{$a,$b}=$c{$b,$a}=$c;
}
#print"a\n";

$v[$g]=1;
push@a,$g;
while(@a){
    die if ++$time>1000;
    #@a=sort{$v[$a]-$v[$b]}@a;
    $a=shift@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) {
		$v[$b]=$v[$a]+$c;
		$p[$b]=$a;
		push@a,$b;
	    }
	}
    }
}
#print"b\n";
print $s;
$a=$s;
do{
    $a=$p[$a];
    print" $a";
}while($a!=$g);
0