結果
| 問題 | No.1473 おでぶなおばけさん |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-08-11 21:47:44 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 581 bytes |
| 記録 | |
| コンパイル時間 | 345 ms |
| コンパイル使用メモリ | 82,444 KB |
| 実行使用メモリ | 266,932 KB |
| 最終ジャッジ日時 | 2024-09-22 04:56:39 |
| 合計ジャッジ時間 | 5,136 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 1 TLE * 1 -- * 45 |
ソースコード
from heapq import heapify, heappop, heappush
from collections import defaultdict
n, m = map(int, input().split())
edge = defaultdict(list)
for _ in range(m):
s, t, d = map(int, input().split())
edge[s].append((t, d))
edge[t].append((s, d))
H = [(-10**18, 0, 1)]
seen = set((1, 10**18))
heapify(H)
while H:
w, cnt, cp = heappop(H)
w *= -1
if cp == n:
print(w, cnt)
break
for np, nw in edge[cp]:
nw = min(nw, w)
if (np, nw) in seen:
continue
seen.add((np, nw))
heappush(H, (-nw, cnt + 1, np))