10282번

· 백준
코드 # bfs로 해결할 수 있을 거라 생각했지만, 가중치가 달라서 다익스트라 알고리즘 이용 import sys, heapq input = sys.stdin.readline INF = 987654321 tc = int(input()) def dijkstra(node, zido, hi): queue = [(0,node)] hi[node] = 0 while queue: now, next = heapq.heappop(queue) if now > hi[next]: continue for i in zido[next]: dist = now + i[1] if hi[i[0]] > dist: hi[i[0]] = dist heapq.heappush(queue, (dist, i[0])) for _ in range(tc): ..