목록알고리즘_백준/그래프이론 (1)
늘
acmicpc_1753(최단경로)
다익스트라 알고리즘을 처음 배우고 풀었던 문제였다. 다익스트라만 적용하면 금방 풀리는 쉬운 문제였다..! #include #include #include #include using namespace std; int answer[20001];//최소 비용 vector line[300001];// 간선 int INF = 2000010; void dijstra(int start) { answer[start] = 0; priority_queue pq; pq.push(make_pair(0, start)); while (!pq.empty()) { int current = pq.top().second; int distance = -pq.top().first;//최소 힙으로 변환 pq.pop(); if (answer[..
알고리즘_백준/그래프이론
2021. 3. 24. 15:50