結果

問題 No.872 All Tree Path
ユーザー tailstails
提出日時 2019-08-30 22:49:29
言語 Perl
(5.38.2)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 254 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 5,336 KB
実行使用メモリ 480,496 KB
最終ジャッジ日時 2023-08-14 06:56:50
合計ジャッジ時間 26,970 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,891 ms
228,220 KB
testcase_01 AC 2,949 ms
228,188 KB
testcase_02 AC 2,903 ms
228,600 KB
testcase_03 AC 2,966 ms
480,496 KB
testcase_04 AC 6 ms
5,172 KB
testcase_05 TLE -
testcase_06 AC 2,995 ms
228,412 KB
testcase_07 AC 2,964 ms
228,124 KB
testcase_08 AC 271 ms
27,644 KB
testcase_09 AC 276 ms
27,668 KB
testcase_10 AC 273 ms
27,720 KB
testcase_11 AC 271 ms
27,796 KB
testcase_12 AC 269 ms
27,704 KB
testcase_13 AC 6 ms
5,292 KB
testcase_14 AC 6 ms
5,092 KB
testcase_15 AC 7 ms
5,072 KB
testcase_16 AC 6 ms
5,188 KB
testcase_17 AC 7 ms
5,076 KB
testcase_18 AC 6 ms
5,076 KB
testcase_19 AC 6 ms
5,092 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

$n=<>;
for(<>){
	($u,$v,$w)=glob<>;
	--$u;
	--$v;
	push@$u,[$v,$w];
	push@$v,[$u,$w];
}
sub f{
	my($x,$y)=@_;
	$vis[$x]=1;
	for(@$x){
		my($z,$w)=@$_;
		if(!$vis[$z]){
			my$y1=f($z);
			$a+=$w*$y1*($n-$y1)*2;
			$y+=$y1;
		}
	}
	$y+1;
}
f(0);
print $a;
0