結果

問題 No.583 鉄道同好会
ユーザー letrangerjpletrangerjp
提出日時 2017-10-28 01:19:59
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 373 bytes
コンパイル時間 246 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 24,220 KB
最終ジャッジ日時 2024-05-01 18:24:20
合計ジャッジ時間 4,972 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, M = gets.split.map &:to_i
edges = []
$<.map{|s|
  a, b = s.split.map &:to_i
  edges << [a, b]
}

used = [false]*M
f=->e{
  return if used[e]
  used[e] = true
  edges[e].each{|a|
    M.times{|i|
      next if edges[i][0]!=a&&edges[i][1]!=a || used[i]
      f[i]
    }
  }
}
f[0]
p used
h=[0]*N
edges.each{|a,b|
  h[a]^=1
  h[b]^=1
}
puts used.all? && h.sum<3 ? :YES : :NO
0