import heapq def dijkstra(s, e): dist = [float('inf') for _ in range(n + 1)] # 초기화 queue = [] heapq.heappush(queue, [0, s]) # 시작 지점 넣기 dist[s] = 0 while queue: d, now = heapq.heappop(queue) # 거리, 현재 정점 if now == e: # 도착 정점이면 중단 break if dist[now] < d: # 가지치기 continue for next in visited[now]: # 현재 정점에서 갈 수 있는 정점 탐방 nd = next[1] + d # 거리 더해주기 if nd < dist[next[0]]: # 출발 정점 ~ 다음 정점까지의 거리보다 작다면 dis..