結果

問題 No.1610 She Loves Me, She Loves Me Not, ...
ユーザー player
提出日時 2023-12-20 15:12:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 765 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 82,340 KB
実行使用メモリ 77,460 KB
最終ジャッジ日時 2024-09-27 09:51:42
合計ジャッジ時間 3,153 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())

edge = [[] for _ in range(n)]
into = [0]*n
for _ in range(m):
    a,b = map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
    into[a-1] += 1
    into[b-1] += 1  
    
start = set()
for i in range(n):
    if into[i] == 1:
        start.add(i)
# print(start)        
cnt = 0
while len(start) > 0:
    tmp = []
    for now in start:
        for next in edge[now]:
            if into[next] <= 0:
                continue
            into[next] -= 1
            into[now] -= 1
            cnt += 1
            if into[next] == 1:
                tmp.append(next)
    # print(tmp)
    start = set()
    for i in tmp:
        start.add(i)
# print(cnt)       
if cnt%2 == 1:
    print("Yes")
else:
    print("No")
0