9370 (1) 썸네일형 리스트형 백준 9370 미확인 도착지 - 파이썬 문제. 풀이. 출발지 s, 경유지 g, h 도착지 d 라고 한다면 두가지 경우의 수 가존재한다. s -> g -> h -> d s -> h -> g -> d 이 2가지를 체크하여 s -> d의 최단경로 거리랑 같다면 정답지에 추가한다. 소스코드. import sys import heapq def dijkstra(start): dp = [100000000 for i in range(n+1)] dp[start] = 0 heap = [] heapq.heappush(heap, [0, start]) while heap: now_weight, now = heapq.heappop(heap) if dp[now] < now_weight: continue for next, weight in graph[now]: next_.. 이전 1 다음