結果

問題 No.1610 She Loves Me, She Loves Me Not, ...
ユーザー wolgnik
提出日時 2021-07-21 21:29:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 600 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 82,528 KB
実行使用メモリ 78,320 KB
最終ジャッジ日時 2024-07-17 16:09:31
合計ジャッジ時間 3,813 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N, M = map(int, input().split())
e = [[] for _ in range(N + 1)]
inc = [0] * (N + 1)
for _ in range(M):
  u, v = map(int, input().split())
  e[u].append(v)
  e[v].append(u)
  inc[u] += 1
  inc[v] += 1

import heapq
hpush = heapq.heappush
hpop = heapq.heappop
h = []
for x in range(1, N + 1):
  hpush(h, (inc[x], x))
res = 0

while len(h):
  c, x = hpop(h)
  if inc[x] != c:
    hpush(h, (inc[x], x))
    continue
  if c != 1: continue
  for y in e[x]:
    inc[y] -= 1
    hpush(h, (inc[y], y))
  inc[x] = 0
  res += 1
  
if res & 1: print("Yes")
else: print("No")
0