vector<int> root, rank;
38root = vector<int>(n + 1);
39rank = vector<int>(n + 1, 1);
40 for(
inti = 1; i <= n; ++i) {
57 returnroot[x] =
Find(root[x]);
81 if(rank[a] < rank[b]) {
83}
else if(rank[a] > rank[b]) {
97 for(
inti = 1; i <= 100; ++i) {
99cout <<
"Fail"<<
endl;
104cout <<
"1 and 2 are initially not in the same subset"<<
endl;
106cout <<
"Fail"<<
endl;
109cout <<
"1 and 2 are now in the same subset"<<
endl;
111cout <<
"Fail"<<
endl;
bool InSameUnion(int x, int y)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4