結果
| 問題 | 
                            No.2202 贅沢てりたまチキン
                             | 
                    
| コンテスト | |
| ユーザー | 
                             titia
                         | 
                    
| 提出日時 | 2023-02-03 23:13:43 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 769 bytes | 
| コンパイル時間 | 316 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 29,696 KB | 
| 最終ジャッジ日時 | 2024-07-02 21:18:26 | 
| 合計ジャッジ時間 | 9,628 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 25 WA * 3 | 
ソースコード
import sys
input = sys.stdin.readline
N,M=map(int,input().split())
# UnionFind
Group = [i for i in range(2*N+1)] # グループ分け
Nodes = [1]*(2*N+1) # 各グループのノードの数
def find(x):
    while Group[x] != x:
        x=Group[x]
    return x
def Union(x,y):
    if find(x) != find(y):
        if Nodes[find(x)] < Nodes[find(y)]:
            
            Nodes[find(y)] += Nodes[find(x)]
            Nodes[find(x)] = 0
            Group[find(x)] = find(y)
            
        else:
            Nodes[find(x)] += Nodes[find(y)]
            Nodes[find(y)] = 0
            Group[find(y)] = find(x)
for i in range(M):
    a,b=map(int,input().split())
    Union(a,b+N)
    Union(a+N,b)
if Nodes[find(1)]==2*N:
    print("Yes")
else:
    print("No")
            
            
            
        
            
titia