結果

問題 No.583 鉄道同好会
ユーザー sca1lsca1l
提出日時 2017-10-27 23:27:44
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 452 bytes
コンパイル時間 141 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 22,048 KB
最終ジャッジ日時 2024-05-01 17:48:34
合計ジャッジ時間 9,070 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
19,232 KB
testcase_01 AC 77 ms
12,288 KB
testcase_02 AC 76 ms
12,288 KB
testcase_03 AC 75 ms
12,160 KB
testcase_04 AC 75 ms
12,160 KB
testcase_05 AC 76 ms
12,160 KB
testcase_06 AC 77 ms
12,288 KB
testcase_07 AC 75 ms
12,288 KB
testcase_08 AC 74 ms
12,160 KB
testcase_09 AC 74 ms
12,288 KB
testcase_10 AC 77 ms
12,160 KB
testcase_11 AC 530 ms
13,184 KB
testcase_12 AC 812 ms
14,208 KB
testcase_13 AC 847 ms
14,080 KB
testcase_14 AC 874 ms
14,208 KB
testcase_15 AC 1,313 ms
14,720 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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 = x.select{|t| t.size>0}.size

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

odd = x.select{|t| t.size%2==1}.size

if odd==0 || odd==2 then
  puts 'YES'
else
  puts 'NO'
end
0