Language: C++

#include<iostream>
#include<iostream>

using namespace std;

class DisjointSet{
  public:
  vector<int> rank, p;

  DisjointSet{}
  DisjointSet(int size){
    rank.resize(size, 0);
    p.resize(size, 0);
    for(int i=0; i<size; i++) makeSet(i);
  }

  void makeSet(int x){
    p[x] = x;
    rank[x] = 0;
  }

  bool same(int x, int y){
    return findSet(x) == findSet(y);
  }

  void link(int x, int y){
    if(rank[x] > rank[y]){
      p[y] = x;
    }else{
      p[x] = y;
      if(rank[x] == rank[y]){
        rank[y]++
      }
    }
  }

  int findSet(int x){
    if(x != p[x]){
      p[x] = fibdSet(p[x]);
    }
    return p[x];
  }
};

int main(){
  int n, a, b, q;
  int t;

  cin >> n >> q;
  DisjointSet ds = DisjointSet(n);
 
  for(int i=0; i<q; i++){
    cin >> t >> a >> b;
    if(t == 0) ds.unite(a, b);
    else if(t == 1){
      if(ds.same(a, b)) cout << 1 << endl;
      else cout << 0 << endl;
    }
  }
  
  return 0;
}
    

Compiler output:
a.cc:8:3: error: 'vector' does not name a type
    8 |   vector<int> rank, p;
      |   ^~~~~~
a.cc:10:14: error: expected unqualified-id before '{' token
   10 |   DisjointSet{}
      |              ^
a.cc: In constructor 'DisjointSet::DisjointSet(int)':
a.cc:12:9: error: expected unqualified-id before '.' token
   12 |     rank.resize(size, 0);
      |         ^
a.cc:13:5: error: 'p' was not declared in this scope
   13 |     p.resize(size, 0);
      |     ^
a.cc: In member function 'void DisjointSet::makeSet(int)':
a.cc:18:5: error: 'p' was not declared in this scope
   18 |     p[x] = x;
      |     ^
a.cc:19:10: error: declaration of 'auto x' shadows a parameter
   19 |     rank[x] = 0;
      |          ^
a.cc:17:20: note: 'int x' previously declared here
   17 |   void makeSet(int x){
      |                ~~~~^
a.cc:19:15: error: class template argument deduction failed:
   19 |     rank[x] = 0;
      |               ^
a.cc:19:15: error: no matching function for call to 'rank(int)'
In file included from /usr/include/c++/14/bits/move.h:37,
                 from /usr/include/c++/14/bits/exception_ptr.h:41,
                 from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/ios:41,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/type_traits:1437:12: note: candidate: 'template<class> rank()-> std::rank< <template-parameter-1-1> >'
 1437 |     struct rank
      |            ^~~~
/usr/include/c++/14/type_traits:1437:12: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/type_traits:1437:12: note: candidate: 'template<class> rank(std::rank< <template-parameter-1-1> >)-> std::rank< <template-parameter-1-1> >'
/usr/include/c++/14/type_traits:1437:12: note:   template argument deduction/substitution failed:
a.cc:19:15: note:   mismatched types 'std::rank< <template-parameter-1-1> >' and 'int'
   19 |     rank[x] = 0;
      |               ^
a.cc: In member function 'void DisjointSet::link(int, int)':
a.cc:27:12: error: expected unqualified-id before '[' token
   27 |     if(rank[x] > rank[y]){
      |            ^
a.cc:28:7: error: 'p' was not declared in this scope
   28 |       p[y] = x;
      |       ^
a.cc:30:7: error: 'p' was not declared in this scope
   30 |       p[x] = y;
      |       ^
a.cc:31:14: error: expected unqualified-id before '[' token
   31 |       if(rank[x] == rank[y]){
      |              ^
a.cc:32:16: error: expected initializer before '++' token
   32 |         rank[y]++
      |                ^~
a.cc:32:16: error: expected ';' before '++' token
a.cc: In member function 'int DisjointSet::findSet(int)':
a.cc:38:13: error: 'p' was not declared in this scope
   38 |     if(x != p[x]){
      |             ^
a.cc:39:14: error: 'fibdSet' was not declared in this scope; did you mean 'findSet'?
   39 |       p[x] = fibdSet(p[x]);
      |              ^~~~~~~
      |              findSet
a.cc:41:12: error: 'p' was not declared in this scope
   41 |     return p[x];
      |            ^
a.cc: In function 'int main()':
a.cc:54:19: error: 'class DisjointSet' has no member named 'unite'
   54 |     if(t == 0) ds.unite(a, b);
      |                   ^~~~~