結果
問題 | No.807 umg tours |
ユーザー |
👑 ![]() |
提出日時 | 2021-03-02 18:24:24 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,352 ms / 4,000 ms |
コード長 | 724 bytes |
コンパイル時間 | 237 ms |
コンパイル使用メモリ | 82,308 KB |
実行使用メモリ | 169,444 KB |
最終ジャッジ日時 | 2024-10-03 01:54:47 |
合計ジャッジ時間 | 15,515 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
ソースコード
import sysfrom heapq import heapify,heappop,heappushinput=sys.stdin.readlinewrite=sys.stdout.writeN,M=map(int,input().split())E=[[] for _ in range(2*N+1)]for _ in range(M):a,b,c=map(int,input().split())E[a].append((b,c))E[a].append((b+N,c))E[a+N].append((b+N,c))E[b].append((a,c))E[b].append((a+N,c))E[b+N].append((a+N,c))inf=float("inf")T=[inf]*(2*N+1)T[1]=0S=[0]*(2*N+1)Q=[(0,1)]while Q:d,x=heappop(Q)if S[x]:continueS[x]=1for y,c in E[x]:if x<=N and N<y:c=0if T[y]>d+c:T[y]=d+cheappush(Q,(d+c,y))X=[T[x]+T[x+N] if x!=1 else 0 for x in range(1,N+1)]write("\n".join(map(str,X)))