Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <set>
- #include <vector>
- #include <deque>
- #define se second
- #define fi first
- #define mp make_pair
- #define pb push_back
- using namespace std;
- vector<int> p;
- vector<int> h;
- int get_root(int x) {
- if (p[x] == x) return x;
- return p[x] = get_root(p[x]);
- }
- void unite(int x, int y) {
- x = get_root(x);
- y = get_root(y);
- if (h[x] < h[y]) swap(x, y);
- p[y] = x;
- if (h[x] == h[y]) h[x]++;
- }
- bool check(int x, int y) {
- return get_root(x) == get_root(y);
- }
- int main() {
- int n, m;
- cin >> n >> m;
- p.resize(n);
- for (int i = 0; i < n; i++) p[i] = i;
- h.assign(n, 1);
- while (m--) {
- ///
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment