結果
問題 |
No.2664 Prime Sum
|
ユーザー |
![]() |
提出日時 | 2024-10-02 00:28:20 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 611 bytes |
コンパイル時間 | 293 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 70,144 KB |
最終ジャッジ日時 | 2024-10-02 00:29:10 |
合計ジャッジ時間 | 3,452 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 WA * 3 |
ソースコード
n,m=map(int,input().split()) graph=[[] for _ in range(n)] for _ in range(m): u,v=map(lambda x:int(x)-1,input().split()) graph[u].append(v) graph[v].append(u) color=[0]*n def bipartite(v,c): res=[0,0] color[v]=c if c==1:res[0]+=1 else:res[1]+=1 for nv in graph[v]: if color[nv]==c:return [-1,-1] elif color[nv]==-c:continue else: black,white=bipartite(nv,-c) if black==-1 or white==-1:return [-1,-1] res[0]+=black res[1]+=white return res print('Yes' if bipartite(0,1)!=[-1,-1] else 'No')