結果
| 問題 | No.1473 おでぶなおばけさん |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-08-11 21:48:40 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 583 bytes |
| 記録 | |
| コンパイル時間 | 152 ms |
| コンパイル使用メモリ | 82,412 KB |
| 実行使用メモリ | 250,724 KB |
| 最終ジャッジ日時 | 2024-09-22 04:57:19 |
| 合計ジャッジ時間 | 4,811 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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))