結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
19,228 KB
testcase_01 AC 87 ms
12,288 KB
testcase_02 AC 85 ms
12,160 KB
testcase_03 AC 84 ms
12,160 KB
testcase_04 AC 88 ms
12,416 KB
testcase_05 AC 86 ms
12,160 KB
testcase_06 AC 88 ms
12,416 KB
testcase_07 AC 88 ms
12,160 KB
testcase_08 AC 87 ms
12,160 KB
testcase_09 AC 86 ms
12,160 KB
testcase_10 AC 88 ms
12,160 KB
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]
h=[0]*N
edges.each{|a,b|
  h[a]^=1
  h[b]^=1
}
puts used.all? && h.sum<3 ? :YES : :NO
0