結果
問題 | No.3087 University Coloring |
ユーザー |
|
提出日時 | 2025-04-04 22:31:23 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 694 bytes |
コンパイル時間 | 219 ms |
コンパイル使用メモリ | 82,900 KB |
実行使用メモリ | 130,860 KB |
最終ジャッジ日時 | 2025-04-04 22:31:42 |
合計ジャッジ時間 | 16,987 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 4 WA * 29 |
ソースコード
from heapq import *n,m=map(int,input().split())connect=[[] for _ in range(n)]for _ in range(m):a,b,c=map(int,input().split())a-=1b-=1connect[a].append((b,c))connect[b].append((a,c))decide=[False]*ninf=10**18dist=[-inf]*ndist[0]=0que=[]que.append((0,0))cnt=0while que:di,now=heappop(que)di*=-1if dist[now]<di:continueif decide[now]:continuedecide[now]=Truecnt+=1if cnt==n:print(dist[now]*2)exit()for to,weight in connect[now]:if not decide[to]:if dist[to]<dist[now]+weight:dist[to]=dist[now]+weightheappush(que,(-dist[to],to))