結果
| 問題 | No.2664 Prime Sum |
| コンテスト | |
| ユーザー |
るこーそー
|
| 提出日時 | 2024-10-02 00:31:31 |
| 言語 | PyPy3 (7.3.23 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 43 ms / 2,000 ms |
| + 612µs | |
| コード長 | 687 bytes |
| 記録 | |
| コンパイル時間 | 67 ms |
| コンパイル使用メモリ | 83,084 KB |
| 実行使用メモリ | 73,716 KB |
| 最終ジャッジ日時 | 2026-09-08 09:59:13 |
| 合計ジャッジ時間 | 3,339 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 37 |
ソースコード
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
for v in range(n):
if color[v]:continue
if bipartite(v,1)==[-1,-1]:
print('No')
exit()
print('Yes')
るこーそー