結果

問題 No.416 旅行会社
ユーザー tailstails
提出日時 2016-08-26 23:20:28
言語 Perl
(5.38.0)
結果
AC  
実行時間 1,411 ms / 4,000 ms
コード長 384 bytes
コンパイル時間 850 ms
コンパイル使用メモリ 7,092 KB
実行使用メモリ 167,304 KB
最終ジャッジ日時 2023-08-21 09:42:41
合計ジャッジ時間 15,397 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 526 ms
82,884 KB
testcase_01 AC 6 ms
5,412 KB
testcase_02 AC 6 ms
5,364 KB
testcase_03 AC 6 ms
5,172 KB
testcase_04 AC 5 ms
5,296 KB
testcase_05 AC 6 ms
5,092 KB
testcase_06 AC 7 ms
5,328 KB
testcase_07 AC 9 ms
5,508 KB
testcase_08 AC 17 ms
6,888 KB
testcase_09 AC 63 ms
13,168 KB
testcase_10 AC 582 ms
83,308 KB
testcase_11 AC 715 ms
167,196 KB
testcase_12 AC 738 ms
167,304 KB
testcase_13 AC 654 ms
167,144 KB
testcase_14 AC 1,357 ms
112,320 KB
testcase_15 AC 1,400 ms
124,348 KB
testcase_16 AC 1,411 ms
138,028 KB
testcase_17 AC 1,370 ms
122,404 KB
testcase_18 AC 1,364 ms
118,720 KB
testcase_19 AC 976 ms
102,704 KB
testcase_20 AC 958 ms
93,828 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

($n,$m,$q)=glob<>;
for(1..$m){
	$ab{<>}=1;
}
for(1..$q){
	delete $ab{$cd[$_]=<>};
}

for(keys%ab){
	/ /;
	push @{$`+0},$'+0;
	push @{$'+0},$`+0;
}
$d=-1;
f(1);

for$d(reverse 1..$q){
	$cd[$d]=~/ /;
	push @{$`+0},$'+0;
	push @{$'+0},$`+0;
	f($`+0) if $v[$'];
	f($'+0) if $v[$`];
}

for(2..$n){
	print $v[$_]+0,$/;
}

sub f {
	my($p)=@_;
	if(!$v[$p]){
		$v[$p]=$d;
		f($_) for@$p;
	}
}
0