結果

問題 No.1610 She Loves Me, She Loves Me Not, ...
ユーザー rlangevinrlangevin
提出日時 2022-12-31 23:42:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 1,087 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 87,204 KB
実行使用メモリ 79,324 KB
最終ジャッジ日時 2023-08-17 22:37:24
合計ジャッジ時間 6,167 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
71,728 KB
testcase_01 AC 96 ms
76,476 KB
testcase_02 AC 92 ms
71,288 KB
testcase_03 AC 95 ms
71,720 KB
testcase_04 AC 89 ms
71,468 KB
testcase_05 AC 155 ms
78,640 KB
testcase_06 AC 142 ms
79,324 KB
testcase_07 AC 142 ms
79,044 KB
testcase_08 AC 140 ms
78,452 KB
testcase_09 AC 140 ms
79,052 KB
testcase_10 AC 139 ms
78,872 KB
testcase_11 AC 140 ms
78,888 KB
testcase_12 AC 136 ms
78,664 KB
testcase_13 AC 139 ms
78,668 KB
testcase_14 AC 99 ms
72,264 KB
testcase_15 AC 99 ms
72,072 KB
testcase_16 AC 106 ms
72,264 KB
testcase_17 AC 107 ms
72,232 KB
testcase_18 AC 107 ms
72,360 KB
testcase_19 AC 107 ms
72,112 KB
testcase_20 AC 101 ms
72,228 KB
testcase_21 AC 99 ms
72,360 KB
testcase_22 AC 100 ms
72,268 KB
testcase_23 AC 91 ms
71,720 KB
testcase_24 AC 91 ms
71,644 KB
testcase_25 AC 91 ms
71,596 KB
testcase_26 AC 91 ms
71,444 KB
testcase_27 AC 89 ms
71,760 KB
testcase_28 AC 90 ms
71,448 KB
testcase_29 AC 90 ms
71,432 KB
testcase_30 AC 90 ms
71,664 KB
testcase_31 AC 90 ms
71,448 KB
testcase_32 AC 90 ms
71,752 KB
testcase_33 AC 91 ms
71,596 KB
testcase_34 AC 90 ms
71,604 KB
testcase_35 AC 91 ms
71,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
def f(G):
    Q = deque()
    S = set()
    N = len(G)
    ans = 0
    # count = dict((u, 0) for u in range(len(G)))
    count = [0] * N

    for u in range(N):
        for v in G[u]:
            count[v] += 1

    for u in range(N):
        if count[u] == 1:
            Q.append(u)
            
    anslst = deque()
    while Q:
        # print("test", count, Q, S)
        u = Q.pop()
        if u not in S:
            ans += 1
            S.add(u)
        anslst.append(u)
        for v in G[u]:
            count[v] -= 1
            count[u] -= 1
            if count[v] == 1:
                Q.append(v)
            if count[v] == 0:
                S.add(v)
            if count[u] == 1:
                Q.append(u)
            if count[u] == 0:
                S.add(u)
    return ans

import sys
readline = sys.stdin.readline


N, M = map(int, readline().split())
G = [[] for i in range(N)]
for i in range(M):
    A, B = map(int, input().split())
    A, B = A - 1, B - 1
    G[A].append(B)
    G[B].append(A)

print("Yes") if f(G) % 2 else print("No")
0