結果

問題 No.583 鉄道同好会
ユーザー tailstails
提出日時 2017-10-27 23:06:15
言語 Perl
(5.38.2)
結果
AC  
実行時間 783 ms / 2,000 ms
コード長 406 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 5,332 KB
実行使用メモリ 51,492 KB
最終ジャッジ日時 2023-08-14 04:36:52
合計ジャッジ時間 4,585 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,092 KB
testcase_01 AC 6 ms
5,064 KB
testcase_02 AC 6 ms
5,332 KB
testcase_03 AC 6 ms
5,056 KB
testcase_04 AC 6 ms
5,072 KB
testcase_05 AC 6 ms
5,056 KB
testcase_06 AC 6 ms
5,320 KB
testcase_07 AC 6 ms
5,148 KB
testcase_08 AC 6 ms
5,168 KB
testcase_09 AC 6 ms
5,252 KB
testcase_10 AC 9 ms
5,416 KB
testcase_11 AC 178 ms
16,120 KB
testcase_12 AC 244 ms
20,532 KB
testcase_13 AC 242 ms
20,728 KB
testcase_14 AC 242 ms
20,536 KB
testcase_15 AC 316 ms
25,060 KB
testcase_16 AC 593 ms
43,016 KB
testcase_17 AC 718 ms
51,184 KB
testcase_18 AC 783 ms
51,492 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Name "main::m" used only once: possible typo at Main.pl line 1.
Main.pl syntax OK

ソースコード

diff #

($n,$m)=glob<>;
@s=map[glob],<>;

for(@s){
	++$d[$a=$_->[0]];
	++$d[$b=$_->[1]];
	vec($e[$a],$b,1)=1;
	vec($e[$b],$a,1)=1;
	vec($h,$a,1)=1;
	vec($h,$b,1)=1;
}
for(0..$n-1){
	$c+=$d[$_]%2;
}
if($c>2){
	print"NO";
	exit;
}

sub f{
	my($a)=@_;
	if(!vec($g,$a,1)){
		vec($g,$a,1)=1;
		for(0..$n-1){
			if(vec($e[$a],$_,1)){
				f($_);
			}
		}
	}
}

f($s[0][0]);
if($g ne $h){
	print"NO";
	exit;
}
print"YES";
0