Algorithm
-
Programmers [섬 연결하기] - 분명 Prim's algorithm...? 을 짰는데..공부/programmers 문제 2019. 10. 1. 11:25
#include #include #include #include #include using namespace std; int arr[100][100]; int visit[100]; priority_queue q; int solution(int n, vector costs) { int answer = 0, cur, s = costs.size(); bool flag = false, skip = false; pair temp; if (n == 1){return 0;} for (int i = 0; i < s; i++) { arr[costs[i][0]][costs[i][1]] = costs[i][2]; arr[costs[i][1]][costs[i][0]] = costs[i][2]; } cur = costs[0][..