結果
| 問題 |
No.583 鉄道同好会
|
| コンテスト | |
| ユーザー |
sca1l
|
| 提出日時 | 2017-10-30 17:17:39 |
| 言語 | Ruby (3.4.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 464 bytes |
| コンパイル時間 | 44 ms |
| コンパイル使用メモリ | 7,296 KB |
| 実行使用メモリ | 28,544 KB |
| 最終ジャッジ日時 | 2024-11-22 10:46:19 |
| 合計ジャッジ時間 | 14,282 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 TLE * 3 |
コンパイルメッセージ
Syntax OK
ソースコード
n,m = gets.split.map(&:to_i)
x = n.times.map{[]}
at = 0
m.times{
a,b=gets.split.map(&:to_i)
at=a
x[a] << b
x[b] << a
}
uni = 0
odd = 0
x.each{|t|
s = t.size
uni += 1 if s>0
odd += 1 if s%2==1
}
con = 0
q = [at]
ch = Array.new(n, false)
while q.size>0
now = q.pop
ch[now] = true
x[now].each{|ne|
next if ch[ne]
q<<ne
}
con+=1
end
if con<uni then
puts 'NO'
exit
end
if odd==0 || odd==2 then
puts 'YES'
else
puts 'NO'
end
sca1l