목록다익스트라 (1)
레야몬
[C++] 1753번 최단경로 - 다익스트라
#include #include #include #define MAX_VERTEX 20001 #define INF 999999999 using namespace std; vector Vertex[MAX_VERTEX]; int Dist[MAX_VERTEX]; int V, E, K; //정점의 개수 V, 간선의 개수 E,시작 정점의 번호 K void Dijkstra() { priority_queue pq; //우선순위 큐 pq.push({0, K}); //처음 위치 Dist[K]=0; while(!pq.empty()) { int Cost = -pq.top().first; //우선순위 큐에서 제일 낮은 가중치를 가진 곳에서 빼오기 int Cur = pq.top().second; pq.pop(); for(int..
알고리즘/백준
2022. 9. 1. 07:18