유니온 파인드 - 강의 내용 보완 (진행 중)
작업 중...
여기서 유니온 파인드 템플릿을 먼저 제공합니다.
다음은 일반적으로 사용되는 두 가지 형태입니다.
경로 압축
int parent[MAXN], n, m;
void init() {
for(int i = 1; i <= n; i++) parent[i] = i;
}
int root(int x) {
if(x != parent[x]) parent[x] = root(parent[x]);
return parent[x];
}
void unite(int x, int y) {
int rx = root(x) ...
10월 13일 09:31에 게시됨