結果
問題 | No.2202 贅沢てりたまチキン |
ユーザー |
|
提出日時 | 2024-11-13 12:49:24 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 816 bytes |
コンパイル時間 | 356 ms |
コンパイル使用メモリ | 82,368 KB |
実行使用メモリ | 225,616 KB |
最終ジャッジ日時 | 2024-11-13 12:49:33 |
合計ジャッジ時間 | 8,525 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 WA * 2 |
ソースコード
from collections import deque N,M = map(int,input().split()) G = {i:[] for i in range(1,N+1)} for _ in range(M): a,b = map(int,input().split()) G[a].append(b) G[b].append(a) col = [set() for _ in range(N+1)] for i in range(1,N+1): if len(col[i])!=0:continue col[i].add(0) que = deque([i]) while que: x = que.popleft() if len(col[x])==1: s = list(col[x])[0] for y in G[x]: if 1-s not in col[y]: col[y].add(1-s) que.append(y) elif len(col[x])==2: for y in G[x]: if len(col[y])==1: col[y] = set([0,1]) que.append(y) flag = "Yes" for i in range(1,N+1): if len(col[i])<2: flag = "No" break print(flag)