結果

問題 No.583 鉄道同好会
ユーザー 0w10w1
提出日時 2017-11-01 23:23:26
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 406 bytes
コンパイル時間 206 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 25,088 KB
最終ジャッジ日時 2024-05-02 04:21:49
合計ジャッジ時間 9,878 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 95 ms
12,288 KB
testcase_02 AC 101 ms
12,416 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 93 ms
12,288 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 95 ms
12,288 KB
testcase_09 AC 91 ms
12,288 KB
testcase_10 AC 100 ms
12,288 KB
testcase_11 AC 467 ms
16,128 KB
testcase_12 AC 606 ms
16,640 KB
testcase_13 AC 595 ms
16,640 KB
testcase_14 AC 605 ms
16,512 KB
testcase_15 AC 758 ms
18,432 KB
testcase_16 AC 1,392 ms
24,704 KB
testcase_17 AC 1,674 ms
24,832 KB
testcase_18 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, M = gets.split.map &:to_i
S = $<.map { |s| eval "[%d, %d].sort" % s.split }
deg = [0] * N
S.each { |t| deg[t[0]] += 1; deg[t[1]] += 1 }
odd = (0...N).select { |i| deg[i] % 2 == 1 }
uf = [-1] * N
S.each { |t| uf[t[0]] = t[0]; uf[t[1]] = t[1] }
anc = lambda { |v| uf[v] == v ? v : uf[v] = anc[uf[v]] }
S.each { |t| uf[anc[t[0]]] = anc[t[1]] }
puts odd.size > 2 || uf.delete(-1).uniq.size > 1 ? :NO : :YES
0