가중치가 있는 단방향 그래프의 왕복 최단거리를 묻는 문제로 정방향, 역방향으로 다익스트라를 그려준 후 합치면 왕복 최단거리를 구할 수 있습니다. (역방향 다익스트라는 돌아오는 경로에 대한 역탐색이기 때문) from heapq import heappop, heappush def dijkstra(graph, start): dp_dists = {i: float('inf') for i in range(1, N + 1)} dp_dists[start] = 0 heap = [] heappush(heap, (0, start)) while heap: cur_dists, cur_node = heappop(heap) for next_node, next_dist in graph[cur_node]: dists = cur_dis..