Given, two disjoint sets with roots 1 and 6 respectively which already have their childrens' paths compressed.
I wish to do a union but instead of
this
I want
this
Unable to figure out a way to do this optimally.
DSU I am using is on cp-algorithms
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3803 |
2 | Benq | 3783 |
3 | Radewoosh | 3602 |
4 | maroonrk | 3575 |
5 | fantasy | 3526 |
6 | ko_osaga | 3500 |
7 | ksun48 | 3491 |
8 | Um_nik | 3486 |
9 | jiangly | 3474 |
10 | orzdevinwang | 3461 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | awoo | 180 |
2 | -is-this-fft- | 177 |
3 | nor | 169 |
4 | Um_nik | 168 |
5 | SecondThread | 164 |
6 | maroonrk | 163 |
7 | adamant | 161 |
8 | kostka | 160 |
9 | YouKn0wWho | 158 |
10 | errorgorn | 153 |
Path compression upon union in DSU
Given, two disjoint sets with roots 1 and 6 respectively which already have their childrens' paths compressed.
I wish to do a union but instead of
I want
Unable to figure out a way to do this optimally.
DSU I am using is on cp-algorithms
Название |
---|