結果
問題 | No.2202 贅沢てりたまチキン |
ユーザー |
|
提出日時 | 2024-11-13 13:36:29 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 960 ms / 2,000 ms |
コード長 | 807 bytes |
コンパイル時間 | 365 ms |
コンパイル使用メモリ | 82,540 KB |
実行使用メモリ | 147,064 KB |
最終ジャッジ日時 | 2024-11-13 13:36:39 |
合計ジャッジ時間 | 8,164 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
from collections import dequeN,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 = [[] for _ in range(N+1)]for i in range(1,N+1):if len(col[i])!=0:continuecol[i].append(0)que = deque([i])while que:x = que.popleft()if len(col[x])==1:s = col[x][0]for y in G[x]:if 1-s not in col[y]:col[y].append(1-s)que.append(y)elif len(col[x])==2:for y in G[x]:if len(col[y])<2:col[y] = [0,1]que.append(y)flag = "Yes"for i in range(1,N+1):if len(col[i])<2:flag = "No"breakprint(flag)