Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <iomanip>//小数精度 	cout << fixed << setprecision(5) << tmp << endl;
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define All(X)      (X).begin(),(X).end()

int  n,q;
int par[10000];
int rank[10000];

void init(int n){
    REP(i,n){
        par[i]=i;
        rank[i]=0;
    }
    return;
}

int find(int x){
    if(par[x]==x){
        return x;
    }else{
        return par[x]=find(par[x]);
    }
}

void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y) return;
    if(rank[x]<rank[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(rank[x]==rank[y]) rank[x]++;
    }
    return;
}

bool same(int x,int y){
    return find(x)==find(y);
}
int main(){
  cin >> n >> q;
    init(n);
    REP(i,q){
        int com,x,y;
        cin >> com >> x >> y;
        if(com==1){
            if(same(x,y)) cout << 1 << endl;
            else cout << 0 << endl;
        }else{
            unite(x,y);
        }
    }
  return 0;
}

Compiler output:
a.cc: In function 'void init(int)':
a.cc:27:9: error: reference to 'rank' is ambiguous
   27 |         rank[i]=0;
      |         ^~~~
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: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:22:5: note:                 'int rank [10000]'
   22 | int rank[10000];
      |     ^~~~
a.cc: In function 'void unite(int, int)':
a.cc:44:8: error: reference to 'rank' is ambiguous
   44 |     if(rank[x]<rank[y]){
      |        ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:22:5: note:                 'int rank [10000]'
   22 | int rank[10000];
      |     ^~~~
a.cc:44:16: error: reference to 'rank' is ambiguous
   44 |     if(rank[x]<rank[y]){
      |                ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:22:5: note:                 'int rank [10000]'
   22 | int rank[10000];
      |     ^~~~
a.cc:48:12: error: reference to 'rank' is ambiguous
   48 |         if(rank[x]==rank[y]) rank[x]++;
      |            ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:22:5: note:                 'int rank [10000]'
   22 | int rank[10000];
      |     ^~~~
a.cc:48:21: error: reference to 'rank' is ambiguous
   48 |         if(rank[x]==rank[y]) rank[x]++;
      |                     ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:22:5: note:                 'int rank [10000]'
   22 | int rank[10000];
      |     ^~~~
a.cc:48:30: error: reference to 'rank' is ambiguous
   48 |         if(rank[x]==rank[y]) rank[x]++;
      |                              ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:22:5: note:                 'int rank [10000]'
   22 | int rank[10000];
      |     ^~~~