結果

問題 No.583 鉄道同好会
ユーザー tailstails
提出日時 2017-10-27 22:50:02
言語 Perl
(5.40.0)
結果
WA  
実行時間 -
コード長 451 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 5,888 KB
実行使用メモリ 52,224 KB
最終ジャッジ日時 2024-11-21 22:41:52
合計ジャッジ時間 4,095 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
Name "main::m" used only once: possible typo at Main.pl line 1.
Main.pl syntax OK

ソースコード

diff #

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

#die if @s!=$m;

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;
die if $a>=$n;
die if $b>=$n;
}
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!=$h){
	print"NO";
	exit;
}
print"YES";
0