結果

問題 No.583 鉄道同好会
ユーザー simansiman
提出日時 2021-11-03 08:41:50
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 395 bytes
コンパイル時間 133 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 15,232 KB
最終ジャッジ日時 2024-04-20 22:12:05
合計ジャッジ時間 3,679 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
12,032 KB
testcase_01 AC 87 ms
12,160 KB
testcase_02 AC 84 ms
12,160 KB
testcase_03 AC 80 ms
12,160 KB
testcase_04 WA -
testcase_05 AC 83 ms
12,032 KB
testcase_06 AC 81 ms
12,160 KB
testcase_07 AC 80 ms
12,160 KB
testcase_08 AC 78 ms
12,160 KB
testcase_09 AC 81 ms
12,160 KB
testcase_10 AC 79 ms
12,160 KB
testcase_11 AC 123 ms
12,800 KB
testcase_12 AC 138 ms
12,928 KB
testcase_13 AC 135 ms
12,928 KB
testcase_14 AC 139 ms
12,928 KB
testcase_15 AC 156 ms
13,440 KB
testcase_16 AC 218 ms
13,952 KB
testcase_17 AC 245 ms
15,232 KB
testcase_18 AC 244 ms
15,232 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, M = gets.split.map(&:to_i)
E = Hash.new { |h, k| h[k] = [] }

M.times do
  a, b = gets.split.map(&:to_i)
  E[a] << b
  E[b] << a
end

def f
  E.all? { |u, list| list.size.even? }
end

def g
  odd_cnt = 0
  even_cnt = 0

  E.each do |u, list|
    if list.size.even?
      even_cnt += 1
    else
      odd_cnt += 1
    end
  end

  odd_cnt == 2
end

if f || g
  puts 'YES'
else
  puts 'NO'
end
0