This repository has been archived on 2022-06-22. You can view files and clone it, but cannot push or open issues or pull requests.
usaco-guide/content/5_Gold/DSU.mdx
2020-06-25 00:00:28 -04:00

57 lines
No EOL
2 KiB
Text

---
id: dsu
title: "Disjoint Set Union"
author: Benjamin Qi, Michael Cao
prerequisites:
- Silver - Depth First Search
description: The Disjoint Set Union (DSU) data structure allows you to add edges to an initially empty graph and test whether two vertices of the graph are connected.
---
import { Problem } from "../models";
export const metadata = {
problems: {
sample: [
new Problem("YS", "Union Find", "unionfind", "Easy", false, []),
],
general: [
new Problem("Gold", "Mootube", "789", "Easy", false, [], "same as [CSES Road Construction](https://cses.fi/problemset/task/1676)"),
new Problem("Gold", "Closing the Farm", "646", "Easy", false, [], "similar to [CSES Network Breakdown](https://cses.fi/problemset/task/1677)"),
new Problem("Gold", "Favorite Colors", "1042", "Hard", false, [], ""),
],
rollback: [
new Problem("YS", "Persistent Union Find", "persistent_unionfind", "Normal", false, [], ""),
new Problem("CF", "Edu F - Extending Set of Points", "contest/1140/problem/F", "Hard", false, [], ""),
],
}
};
<problems-list problems={metadata.problems.sample} />
## Tutorial
- CPH 15.2
- [PAPS 11.1](https://www.csc.kth.se/~jsannemo/slask/main.pdf)
- Chapter 10.6 of "An Introduction to the US Computing Olympiad"
- [CSAcademy Disjoint-Set](https://csacademy.com/lesson/disjoint_data_sets)
- [Topcoder Union Find](https://www.topcoder.com/community/data-science/data-science-tutorials/disjoint-set-data-structures/)
- [CPC.3](https://github.com/SuprDewd/T-414-AFLV/tree/master/03_data_structures)
<optional-content title="DSU Complexity Proofs">
- [$\log^* n$](https://en.wikipedia.org/wiki/Proof_of_O(log*n)\_time_complexity\_of_union%E2%80%93find)
- [$\alpha (m,n)$](https://dl.acm.org/doi/pdf/10.1145/321879.321884)
</optional-content>
## Problems
<problems-list problems={metadata.problems.general} />
## Rollback
no path compression
<problems-list problems={metadata.problems.rollback} />
https://judge.yosupo.jp/problem/dynamic_graph_vertex_add_component_sum