5972번

· 백준
코드 import sys, heapq input = sys.stdin.readline INF = 987654321 n,m = map(int, input().split()) graph = [[] for _ in range(n+1)] visited = [INF]*(n+1) for _ in range(m): a,b,c = map(int, input().split()) graph[a].append((b,c)) graph[b].append((a,c)) def dijkstra(): queue = [(0,1)] visited[1] = 0 while queue: cost, vertex = heapq.heappop(queue) if cost > visited[vertex]: continue for ver in graph..