nq1s788

снм

May 4th, 2025
557
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <set>
  3. #include <vector>
  4. #include <deque>
  5.  
  6. #define se second
  7. #define fi first
  8. #define mp make_pair
  9. #define pb push_back
  10.  
  11. using namespace std;
  12.  
  13. vector<int> p;
  14. vector<int> h;
  15.  
  16. int get_root(int x) {
  17.     if (p[x] == x) return x;
  18.     return p[x] = get_root(p[x]);
  19. }
  20.  
  21. void unite(int x, int y) {
  22.     x = get_root(x);
  23.     y = get_root(y);
  24.     if (h[x] < h[y]) swap(x, y);
  25.     p[y] = x;
  26.     if (h[x] == h[y]) h[x]++;
  27. }
  28.  
  29. bool check(int x, int y) {
  30.     return get_root(x) == get_root(y);
  31. }
  32.  
  33. int main() {
  34.     int n, m;
  35.     cin >> n >> m;
  36.     p.resize(n);
  37.     for (int i = 0; i < n; i++) p[i] = i;
  38.     h.assign(n, 1);
  39.     while (m--) {
  40.         ///
  41.     }
  42.     return 0;
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment