반응형 최소신장트리1 최소신장트리 (MST) 핵심 코드 | c++ 최소신장트리의 가장 기본이 되는 코드입니다. 해당 유형의 문제들은 다 이 코드를 수정해서 풀이할 수 있을 것입니다. 사실 최소신장트리의 핵심은 union find 이기 때문에 최소신장트리라고 지칭하는것 보다 union find 응용 문제라고 하는것이 더 나을지 모릅니다. int parent[10001]; struct node { int start; int end; int dist; node(int a, int b, int c) { start = a; end = b; dist = c; } }; struct compare { bool operator()(node a, node b) { return a.dist > b.dist; } }; priority_queue v; int find(int u) { if(u.. 2021. 2. 19. 이전 1 다음 반응형