結果
| 問題 | No.1473 おでぶなおばけさん |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-09 22:52:56 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 703 bytes |
| 記録 | |
| コンパイル時間 | 173 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 101,408 KB |
| 最終ジャッジ日時 | 2024-06-25 06:36:43 |
| 合計ジャッジ時間 | 21,779 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 17 WA * 30 |
ソースコード
n,m=map(int,input().split())
edge=[[] for i in range(n)]
for i in range(m):
s,t,d=map(int,input().split())
s-=1;t-=1
edge[s].append((t,d*-1))
edge[t].append((s,d*-1))
from heapq import heappop,heappush
def dijkstra(s,n,edge):
inf=float("inf")
ans=[inf]*n
ans[s]=-inf
root=[0]*n
open=[[-inf,s]]
while open:
cost,node=heappop(open)
if ans[node]<cost:
continue
for next,e_cost in edge[node]:
if max(cost,e_cost)<ans[next]:
ans[next]=max(cost,e_cost)
root[next]=root[node]+1
heappush(open,[max(cost,e_cost),next])
return ans[-1]*-1,root[-1]
print(*dijkstra(0,n,edge))