結果
| 問題 | 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-=1
    b-=1
    connect[a].append((b,c))
    connect[b].append((a,c))
decide=[False]*n
inf=10**18
dist=[-inf]*n
dist[0]=0
que=[]
que.append((0,0))
cnt=0
while que:
    di,now=heappop(que)
    di*=-1
    if dist[now]<di:
        continue
    if decide[now]:
        continue
    decide[now]=True
    cnt+=1
    if 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]+weight
                heappush(que,(-dist[to],to))
            
            
            
        