結果

問題 No.1610 She Loves Me, She Loves Me Not, ...
ユーザー playerplayer
提出日時 2023-12-20 14:55:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,757 bytes
コンパイル時間 785 ms
コンパイル使用メモリ 81,828 KB
実行使用メモリ 77,108 KB
最終ジャッジ日時 2023-12-20 14:55:21
合計ジャッジ時間 4,569 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,332 KB
testcase_01 AC 45 ms
63,916 KB
testcase_02 WA -
testcase_03 AC 37 ms
53,332 KB
testcase_04 AC 37 ms
53,332 KB
testcase_05 AC 102 ms
76,852 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 113 ms
76,724 KB
testcase_09 AC 103 ms
76,724 KB
testcase_10 AC 106 ms
76,852 KB
testcase_11 AC 104 ms
76,724 KB
testcase_12 AC 105 ms
76,724 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 46 ms
61,128 KB
testcase_17 AC 50 ms
61,128 KB
testcase_18 WA -
testcase_19 AC 49 ms
61,128 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 35 ms
53,332 KB
testcase_25 AC 36 ms
53,332 KB
testcase_26 AC 39 ms
53,332 KB
testcase_27 WA -
testcase_28 AC 35 ms
53,332 KB
testcase_29 AC 36 ms
53,332 KB
testcase_30 AC 35 ms
53,332 KB
testcase_31 AC 35 ms
53,332 KB
testcase_32 AC 35 ms
53,332 KB
testcase_33 AC 34 ms
53,332 KB
testcase_34 AC 34 ms
53,332 KB
testcase_35 AC 34 ms
53,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import pypyjit
pypyjit.set_param('max_unroll_recursion=-1')
import sys
sys.setrecursionlimit(10**7)

# UnionFind
class UnionFind:
    def __init__(self,n):
        self.n=n
        self.parent_size=[-1]*n
 
    def leader(self,a):
        if self.parent_size[a]<0: return a
        self.parent_size[a]=self.leader(self.parent_size[a])
        return self.parent_size[a]
 
    def merge(self,a,b):
        x,y=self.leader(a),self.leader(b)
        if x == y: return 
        if abs(self.parent_size[x])<abs(self.parent_size[y]):x,y=y,x
        self.parent_size[x] += self.parent_size[y]
        self.parent_size[y]=x
        return 
 
    def same(self,a,b):
        return self.leader(a) == self.leader(b)
 
    def size(self,a):
        return abs(self.parent_size[self.leader(a)])
 
    def groups(self):
        result=[[] for _ in range(self.n)]
        for i in range(self.n):
            result[self.leader(i)].append(i)
        return [r for r in result if r != []]
    
n,m = map(int,input().split())

edge = [[] for _ in range(n)]
uf = UnionFind(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)
    uf.merge(a-1,b-1)
    into[a-1] += 1
    into[b-1] += 1  

ans = 0

def dfs(now):
    global ans
    for to in edge[now]:
        if into[to] == 0:
            continue
        if into[to] == 1:
            into[to] = 0
            ans += 1
            dfs(to)
        elif into[to] >= 2:
            into[to] -= 1
            
        
        
l = uf.groups()
for lis in l:
    tmp = []
    for now in lis:
        if into[now] == 1:
            tmp.append(now)
    for i in tmp:
        dfs(i)
        
if (ans-1)%2 == 0:
    print("Yes")
else:
    print("No")
            
0