結果
| 問題 |
No.1473 おでぶなおばけさん
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-12-04 14:13:04 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 583 bytes |
| コンパイル時間 | 218 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 142,700 KB |
| 最終ジャッジ日時 | 2024-12-04 14:13:41 |
| 合計ジャッジ時間 | 30,048 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 45 TLE * 2 |
ソースコード
import heapq
n,m=map(int,input().split())
a=[[]for _ in range(m)]
for _ in range(m):
s,t,d=map(int,input().split())
s,t=s-1,t-1
a[s].append((t,d))
a[t].append((s,d))
q=[]
heapq.heapify(q)
heapq.heappush(q,(0,-10**18,0))
dist=[[0]*2 for _ in range(n)]
dist[0][0]=10**18
while q:
distanc,dis,now=heapq.heappop(q)
dis=-dis
if dis<dist[now][0]:
continue
for next,ndi in a[now]:
v=min(dis,ndi)
if dist[next][0]>=v:
continue
dist[next][0]=v
dist[next][1]=distanc+1
heapq.heappush(q,(distanc+1,-v,next))
print(dist[n-1][0],dist[n-1][1])