Language: C++

#include<bits/stdc++.h>

using namespace std;

vector<int>link;
vector<int>S;

int find(int x){
    return link[x] = ((link[x]!=x)?find(link[x]):x);
}

void unite(int a, int b){
    a = find(a);
    b = find(b);

    if(S[a]<S[b]){
        swap(a,b);
    }

    S[a] += S[b];
    link[b] = a;
}

void solve(int n, int q){
    S.assign(n,1);
    link.reS(n);

    for(int i=0;i<n;i++){
        link[i] = i;
    }

    int opt,u,v;
    while(q--){
        cin>>opt>>u>>v;

        if(opt==0){
            unite(u,v);
            continue;
        }

        if(opt==1){
            cout<<(find(u) == find(v))<<endl;
            continue;
        }
    }
}

int main(){
    int n,q;
    cin>>n>>q;
    solve(n,q);

    return 0;
}

Compiler output:
a.cc:5:12: error: 'std::vector<int> link' redeclared as different kind of entity
    5 | vector<int>link;
      |            ^~~~
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
                 from /usr/include/signal.h:328,
                 from /usr/include/c++/14/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:116,
                 from a.cc:1:
/usr/include/unistd.h:819:12: note: previous declaration 'int link(const char*, const char*)'
  819 | extern int link (const char *__from, const char *__to)
      |            ^~~~
a.cc: In function 'int find(int)':
a.cc:9:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
    9 |     return link[x] = ((link[x]!=x)?find(link[x]):x);
      |                  ^
a.cc:9:30: warning: pointer to a function used in arithmetic [-Wpointer-arith]
    9 |     return link[x] = ((link[x]!=x)?find(link[x]):x);
      |                              ^
a.cc:9:31: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    9 |     return link[x] = ((link[x]!=x)?find(link[x]):x);
      |                        ~~~~~~~^~~
a.cc:9:47: warning: pointer to a function used in arithmetic [-Wpointer-arith]
    9 |     return link[x] = ((link[x]!=x)?find(link[x]):x);
      |                                               ^
a.cc:9:40: error: no matching function for call to 'find(int (&)(const char*, const char*) noexcept)'
    9 |     return link[x] = ((link[x]!=x)?find(link[x]):x);
      |                                    ~~~~^~~~~~~~~
a.cc:8:5: note: candidate: 'int find(int)' (near match)
    8 | int find(int x){
      |     ^~~~
a.cc:8:5: note:   conversion of argument 1 would be ill-formed:
a.cc:9:47: error: invalid conversion from 'int (*)(const char*, const char*) noexcept' to 'int' [-fpermissive]
    9 |     return link[x] = ((link[x]!=x)?find(link[x]):x);
      |                                         ~~~~~~^
      |                                               |
      |                                               int (*)(const char*, const char*) noexcept
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)'
 3842 |     find(_InputIterator __first, _InputIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:3842:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
   60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note:   candidate expects 4 arguments, 1 provided
In file included from /usr/include/c++/14/iterator:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   candidate expects 3 arguments, 1 provided
a.cc: In function 'void unite(int, int)':
a.cc:21:11: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   21 |     link[b] = a;
      |           ^
a.cc:21:13: error: assignment of read-only location '*(link + ((sizetype)b))'
   21 |     link[b] = a;
      |     ~~~~~~~~^~~
a.cc: In function 'void solve(int, int)':
a.cc:26:10: error: request for member 'reS' in 'link', which is of non-class type 'int(const char*, const char*) noexcept'
   26 |     link.reS(n);
      |          ^~~
a.cc:29:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   29 |         link[i] = i;
      |               ^
a.cc:29:17: error: assignment of read-only location '*(link + ((sizetype)i))'
   29 |         link[i] = i;
      |         ~~~~~~~~^~~