結果

問題 No.1610 She Loves Me, She Loves Me Not, ...
ユーザー vwxyz
提出日時 2024-08-09 05:58:53
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 526 bytes
コンパイル時間 485 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,648 KB
最終ジャッジ日時 2024-08-09 05:58:56
合計ジャッジ時間 3,125 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int,input().split())
graph=[[] for x in range(N)]
degree=[0]*N
for m in range(M):
    a,b=map(int,input().split())
    a-=1;b-=1
    graph[a].append(b)
    graph[b].append(a)
    degree[a]+=1
    degree[b]+=1
queue=[]
for x in range(N):
    if degree[x]==1:
        queue.append(x)
cnt=0
while queue:
    x=queue.pop()
    if degree[x]!=1:
        continue
    cnt+=1
    for y in graph[x]:
        degree[y]-=1
        if degree[y]==1:
            queue.append(y)
if cnt%2:
    ans="Yes"
else:
    ans="No"
print(ans)
0