結果
| 問題 |
No.2202 贅沢てりたまチキン
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-11-13 13:18:53 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 808 bytes |
| コンパイル時間 | 498 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 146,848 KB |
| 最終ジャッジ日時 | 2024-11-13 13:19:02 |
| 合計ジャッジ時間 | 7,673 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 = [[] for _ in range(N+1)]
for i in range(1,N+1):
if len(col[i])!=0:continue
col[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])==1:
col[y] = [0,1]
que.append(y)
flag = "Yes"
for i in range(1,N+1):
if len(col[i])<2:
flag = "No"
break
print(flag)