結果

問題 No.556 仁義なきサルたち
ユーザー %20%20
提出日時 2018-01-10 01:24:22
言語 Perl
(5.38.2)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 227 bytes
コンパイル時間 578 ms
コンパイル使用メモリ 5,368 KB
実行使用メモリ 7,212 KB
最終ジャッジ日時 2023-08-25 02:30:18
合計ジャッジ時間 1,881 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,664 KB
testcase_01 AC 2 ms
4,664 KB
testcase_02 AC 2 ms
4,476 KB
testcase_03 AC 3 ms
4,752 KB
testcase_04 AC 2 ms
4,660 KB
testcase_05 AC 3 ms
4,800 KB
testcase_06 AC 3 ms
4,556 KB
testcase_07 AC 3 ms
4,556 KB
testcase_08 AC 3 ms
4,684 KB
testcase_09 AC 4 ms
4,708 KB
testcase_10 AC 5 ms
4,828 KB
testcase_11 AC 5 ms
4,872 KB
testcase_12 AC 6 ms
4,900 KB
testcase_13 AC 8 ms
5,528 KB
testcase_14 AC 13 ms
5,712 KB
testcase_15 AC 16 ms
5,776 KB
testcase_16 AC 18 ms
6,420 KB
testcase_17 AC 24 ms
6,432 KB
testcase_18 AC 34 ms
7,012 KB
testcase_19 AC 32 ms
7,188 KB
testcase_20 AC 34 ms
7,060 KB
testcase_21 AC 34 ms
7,212 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

sub f{my$i=0+pop;
	$p[$i]=$i==$p[$i]?$i:f($p[$i])
}
map$n[$_]=1,1..map$p[$_]=$_,1..<>;
for(<>){
	/ /;
	next if($A=f$`)==($B=f$');
	($A,$B)=sort{$n[$b]-$n[$a]||$a-$b}$A,$B;
	$n[$A]+=$n[$B];
	$p[$B]=$A
}
print f($_),$/for 1..$#p
0