結果

問題 No.1473 おでぶなおばけさん
コンテスト
ユーザー いた
提出日時 2024-12-04 14:13:04
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 583 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 554 ms
コンパイル使用メモリ 65,192 KB
実行使用メモリ 111,444 KB
最終ジャッジ日時 2026-10-13 13:15:14
合計ジャッジ時間 28,753 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 47 WA * 1 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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])
      
0