結果

問題 No.1610 She Loves Me, She Loves Me Not, ...
ユーザー 👑 rin204
提出日時 2021-12-13 01:38:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 621 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 82,376 KB
実行使用メモリ 77,184 KB
最終ジャッジ日時 2024-07-21 15:16:06
合計ジャッジ時間 3,372 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
cnt = [0] * n
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    cnt[a] += 1
    cnt[b] += 1
    edges[a].append(b)
    edges[b].append(a)
    
stack = []
for i in range(n):
    if cnt[i] == 1:
        stack.append(i)

ans = False
while stack:
    pos = stack.pop()
    if cnt[pos] == 1:
        ans ^= True
        cnt[pos] -= 1
    else:
        continue
    
    for npos in edges[pos]:
        cnt[npos] -= 1
        if cnt[npos] == 1:
            stack.append(npos)
        
if ans:
    print("Yes")
else:
    print("No")
0