結果
問題 |
No.583 鉄道同好会
|
ユーザー |
![]() |
提出日時 | 2017-10-27 23:31:48 |
言語 | Ruby (3.4.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 462 bytes |
コンパイル時間 | 217 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 27,136 KB |
最終ジャッジ日時 | 2024-11-21 23:27:00 |
合計ジャッジ時間 | 15,647 ms |
ジャッジサーバーID (参考情報) |
judge5 / 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.shift 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