結果

問題 No.416 旅行会社
ユーザー %20%20
提出日時 2018-08-01 00:51:01
言語 Perl
(5.38.2)
結果
AC  
実行時間 2,123 ms / 4,000 ms
コード長 447 bytes
コンパイル時間 413 ms
コンパイル使用メモリ 5,312 KB
実行使用メモリ 155,200 KB
最終ジャッジ日時 2023-08-21 10:19:40
合計ジャッジ時間 21,436 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 875 ms
118,512 KB
testcase_01 AC 7 ms
5,116 KB
testcase_02 AC 6 ms
5,128 KB
testcase_03 AC 6 ms
5,128 KB
testcase_04 AC 6 ms
5,088 KB
testcase_05 AC 7 ms
5,280 KB
testcase_06 AC 7 ms
5,300 KB
testcase_07 AC 11 ms
5,672 KB
testcase_08 AC 26 ms
7,640 KB
testcase_09 AC 112 ms
17,728 KB
testcase_10 AC 899 ms
118,564 KB
testcase_11 AC 941 ms
118,940 KB
testcase_12 AC 960 ms
122,884 KB
testcase_13 AC 881 ms
118,768 KB
testcase_14 AC 2,123 ms
154,960 KB
testcase_15 AC 2,048 ms
154,552 KB
testcase_16 AC 1,975 ms
155,200 KB
testcase_17 AC 2,056 ms
155,108 KB
testcase_18 AC 2,076 ms
155,088 KB
testcase_19 AC 1,526 ms
131,088 KB
testcase_20 AC 1,547 ms
130,616 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

sub f{my$i=pop;$p[$i]=$p[$i]&&$i-$p[$i]?f($p[$i]):$i}
($N,$M,$Q)=glob<>;
map@$_=$_,1..$N;
@AB=map~~<>,1..$M;
++$h{$_}for@CD=<>;
$-=@AB=grep!$h{$_},@AB;
for(@AB,reverse@CD){
	/ /;
	$x=f$`;
	$y=f$'+0;
	if($x==f(1)&&$y!=f(1)){
		$o[$_]=$-?-1:$Q for@$y
	}elsif($x!=f(1)&&$y==f(1)){
		$o[$_]=$-?-1:$Q for@$x
	}
	if($x!=$y){
		if(@$x<@$y){
			$p[$x]=$y;
			push@$y,@$x
		}else{
			$p[$y]=$x;
			push@$x,@$y
		}
	}
	$---||--$Q
}
print$_+0,$/for@o[2..$N]
0