結果

問題 No.1610 She Loves Me, She Loves Me Not, ...
ユーザー Akijin_007
提出日時 2022-11-04 13:39:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 668 bytes
コンパイル時間 142 ms
コンパイル使用メモリ 82,268 KB
実行使用メモリ 77,416 KB
最終ジャッジ日時 2024-07-18 13:19:16
合計ジャッジ時間 2,713 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#int(input())
#map(int, input().split())
#list(map(int, input().split()))

N, M = map(int, input().split())

to = [[] for i in range(N)]
d = [0] * N

for i in range(M):
    l, r = map(int, input().split())
    to[l-1].append(r-1)
    to[r-1].append(l-1)
    d[l-1] += 1
    d[r-1] += 1

ans = 0

q = []

for i in range(N):
    if d[i] == 1:
        q.append(i)

v = [0] * N

while q:
    t = q.pop()
    if v[t] == 1:
        continue
    v[t] = 1

    for x in to[t]:
        if v[x] == 1:
            continue
        d[x] -= 1
        ans += 1
        if d[x] == 1:
            q.append(x)

# print(ans)
if ans % 2 == 0:
    print("No")
else:
    print("Yes")





0