結果

問題 No.583 鉄道同好会
ユーザー fiord
提出日時 2017-10-27 23:37:06
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 581 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 15,744 KB
最終ジャッジ日時 2024-11-21 23:31:59
合計ジャッジ時間 4,020 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n,m=gets.split(" ").map(&:to_i)
cnt=Array.new(n,0)
@edge=Array.new(n){[]}
m.times{
    a,b=gets.split(" ").map(&:to_i)
    cnt[a]^=1
    cnt[b]^=1
    @edge[a].<<b
    @edge[b].<<a
}
@visit=Array.new(n,false)
def dfs(i)
    @visit[i]=true
    for j in @edge[i] do
        if !@visit[j] then
            dfs(j)
        end
    end
end
def check()
    for i in 0...@edge.length do
        if @edge[i]!=[]&&@visit[i]==false then
            return false
        end
    end
    return true
end
dfs(0)
if check()&&[0,2].include?(cnt.count(1)) then
    puts "YES"
else
    puts "NO"
end
0