結果

問題 No.583 鉄道同好会
ユーザー fiordfiord
提出日時 2017-10-27 23:40:22
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 607 bytes
コンパイル時間 66 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 15,744 KB
最終ジャッジ日時 2024-05-01 17:57:34
合計ジャッジ時間 3,613 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
12,160 KB
testcase_01 AC 87 ms
12,160 KB
testcase_02 AC 90 ms
12,288 KB
testcase_03 AC 88 ms
12,160 KB
testcase_04 AC 89 ms
12,288 KB
testcase_05 AC 88 ms
12,288 KB
testcase_06 WA -
testcase_07 AC 91 ms
12,288 KB
testcase_08 AC 91 ms
12,288 KB
testcase_09 AC 89 ms
12,288 KB
testcase_10 AC 92 ms
12,160 KB
testcase_11 AC 146 ms
13,184 KB
testcase_12 AC 166 ms
13,568 KB
testcase_13 AC 167 ms
13,440 KB
testcase_14 AC 171 ms
13,568 KB
testcase_15 AC 190 ms
14,080 KB
testcase_16 AC 275 ms
14,592 KB
testcase_17 AC 319 ms
15,744 KB
testcase_18 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n,m=gets.split(" ").map(&:to_i)
cnt=Array.new(n,0)
@edge=Array.new(n){[]}
@visit=Array.new(n){true}
m.times{
    a,b=gets.split(" ").map(&:to_i)
    cnt[a]^=1
    cnt[b]^=1
    @edge[a].<<b
    @edge[b].<<a
    @visit[a]=false
    @visit[b]=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 @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