結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
12,288 KB
testcase_01 AC 86 ms
12,160 KB
testcase_02 AC 83 ms
12,160 KB
testcase_03 AC 88 ms
12,032 KB
testcase_04 AC 84 ms
12,160 KB
testcase_05 AC 84 ms
12,160 KB
testcase_06 WA -
testcase_07 AC 84 ms
12,288 KB
testcase_08 AC 84 ms
12,160 KB
testcase_09 AC 84 ms
12,160 KB
testcase_10 AC 85 ms
12,160 KB
testcase_11 AC 142 ms
13,056 KB
testcase_12 AC 162 ms
13,312 KB
testcase_13 AC 163 ms
13,312 KB
testcase_14 AC 159 ms
13,568 KB
testcase_15 AC 182 ms
14,080 KB
testcase_16 AC 267 ms
14,720 KB
testcase_17 AC 301 ms
15,616 KB
testcase_18 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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