結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,800 KB
testcase_01 AC 3 ms
4,688 KB
testcase_02 AC 3 ms
4,672 KB
testcase_03 AC 3 ms
4,680 KB
testcase_04 AC 76 ms
6,320 KB
testcase_05 AC 140 ms
8,044 KB
testcase_06 AC 192 ms
10,000 KB
testcase_07 AC 24 ms
5,672 KB
testcase_08 AC 35 ms
5,548 KB
testcase_09 AC 33 ms
5,424 KB
testcase_10 AC 32 ms
5,740 KB
testcase_11 AC 36 ms
5,976 KB
testcase_12 AC 37 ms
5,452 KB
testcase_13 AC 29 ms
5,444 KB
testcase_14 AC 27 ms
5,708 KB
testcase_15 AC 25 ms
5,296 KB
testcase_16 AC 42 ms
5,444 KB
testcase_17 AC 29 ms
5,440 KB
testcase_18 AC 32 ms
5,496 KB
testcase_19 AC 42 ms
5,368 KB
testcase_20 AC 49 ms
5,508 KB
testcase_21 AC 23 ms
5,412 KB
testcase_22 AC 25 ms
5,332 KB
testcase_23 AC 37 ms
5,796 KB
testcase_24 AC 41 ms
5,764 KB
testcase_25 AC 29 ms
5,380 KB
testcase_26 AC 31 ms
5,312 KB
testcase_27 AC 13 ms
4,792 KB
testcase_28 AC 113 ms
13,316 KB
testcase_29 AC 13 ms
4,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
}
#print"a\n";

$v[$g]=1;
push@a,$g;
while(@a){
    #@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