結果

問題 No.1610 She Loves Me, She Loves Me Not, ...
ユーザー maguroflymagurofly
提出日時 2021-07-21 21:32:47
言語 Ruby
(3.3.0)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 704 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 11,252 KB
実行使用メモリ 15,684 KB
最終ジャッジ日時 2023-09-24 15:33:19
合計ジャッジ時間 5,174 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,128 KB
testcase_01 AC 84 ms
15,236 KB
testcase_02 AC 81 ms
15,184 KB
testcase_03 AC 82 ms
15,204 KB
testcase_04 AC 83 ms
15,132 KB
testcase_05 AC 94 ms
15,432 KB
testcase_06 AC 94 ms
15,488 KB
testcase_07 AC 93 ms
15,684 KB
testcase_08 AC 92 ms
15,520 KB
testcase_09 AC 90 ms
15,564 KB
testcase_10 AC 92 ms
15,492 KB
testcase_11 AC 93 ms
15,552 KB
testcase_12 AC 93 ms
15,412 KB
testcase_13 AC 92 ms
15,572 KB
testcase_14 AC 83 ms
15,068 KB
testcase_15 AC 84 ms
15,244 KB
testcase_16 AC 82 ms
15,324 KB
testcase_17 AC 84 ms
15,168 KB
testcase_18 AC 83 ms
15,296 KB
testcase_19 AC 83 ms
15,136 KB
testcase_20 AC 83 ms
15,164 KB
testcase_21 AC 85 ms
15,304 KB
testcase_22 AC 83 ms
15,164 KB
testcase_23 AC 81 ms
15,204 KB
testcase_24 AC 82 ms
15,104 KB
testcase_25 AC 82 ms
15,164 KB
testcase_26 AC 81 ms
15,252 KB
testcase_27 AC 81 ms
15,360 KB
testcase_28 AC 82 ms
15,160 KB
testcase_29 AC 82 ms
15,276 KB
testcase_30 AC 81 ms
15,160 KB
testcase_31 AC 82 ms
15,164 KB
testcase_32 AC 82 ms
15,244 KB
testcase_33 AC 83 ms
15,188 KB
testcase_34 AC 82 ms
15,164 KB
testcase_35 AC 81 ms
15,308 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, M = gets.split.map(&:to_i)
graph = Array.new(N) { [] }
M.times do
    a, b = gets.split.map { |s| s.to_i - 1 }
    graph[a] << b
    graph[b] << a
end

removed = [false] * N
inqueue = [false] * N
ones = (0 ... N).filter { |v| graph[v].size == 1 }
ones.each do |v|
    inqueue[v] = true
end
while (u = ones.pop)
    next if removed[u] or graph[u].size != 1
    removed[u] = true
    # STDERR.puts graph[u].inspect
    graph[u].each do |v|
        next if removed[v]
        graph[v].delete(u)
        if graph[v].size == 1 and not inqueue[v]
            ones << v
            inqueue[v] = true
        end
    end
    graph[u].clear
end

c = removed.count(true)
STDERR.puts c
puts c.odd? ? "Yes" : "No"
0