結果
問題 | No.2664 Prime Sum |
ユーザー | flygon |
提出日時 | 2024-03-08 21:38:03 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 57 ms / 2,000 ms |
コード長 | 868 bytes |
コンパイル時間 | 235 ms |
コンパイル使用メモリ | 82,004 KB |
実行使用メモリ | 64,512 KB |
最終ジャッジ日時 | 2024-09-29 19:01:52 |
合計ジャッジ時間 | 3,119 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 37 |
ソースコード
import syssys.setrecursionlimit(5*10**5)input = sys.stdin.readlinefrom collections import defaultdict, deque, Counterfrom heapq import heappop, heappushfrom bisect import bisect_left, bisect_rightfrom math import gcdn,m = map(int,input().split())graph = [[] for i in range(n+1)]for i in range(m):u,v = map(int,input().split())graph[u].append(v)graph[v].append(u)depth = [-1]*(n+1)def bfs(s, n):que = deque([s])depth[s] = 0ok = 1while que:crr = que.popleft()for nxt in graph[crr]:if depth[nxt] == -1:depth[nxt] = depth[crr]^1que.append(nxt)elif depth[nxt]^1 != depth[crr]:ok = 0return okans = 1for i in range(1,n+1):if depth[i] != -1: continueans &= bfs(i, n)if ans:print('Yes')else:print('No')