Language: C++

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;

const int MAX = 2E5+5;
int link[MAX], size[MAX];

int find(int a){
	if (link[a] == a)
		return a;
	else{
		link[a] = find(link[a]);
		return link[a];
	}
}

void unite(int a, int b){
	a = find(a);
	b = find(b);
	if (a == b) return;
	if (size[a] < size[b]) swap(a,b);
	size[a] += size[b];
	link[b] = a;
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,q;

    cin >> n >> q;
    for (int i=0; i<n; ++i){
    	link[i] = i;
    	size[i] = 1;
    }
    for (int i=0; i<q; ++i){
    	int t,u,v;
    	cin >> t >> u >> v;
    	if (t == 0){
    		unite(u,v);
    	}else{
    		u = find(u);
    		v = find(v);
    		cout << (u == v) << endl;
    	}
    }

    
	return 0;
}

Compiler output:
a.cc:11:13: error: 'int link [200005]' redeclared as different kind of entity
   11 | int link[MAX], size[MAX];
      |             ^
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:14:19: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   14 |         if (link[a] == a)
      |                   ^
a.cc:14:21: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   14 |         if (link[a] == a)
      |             ~~~~~~~~^~~~
a.cc:17:23: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   17 |                 link[a] = find(link[a]);
      |                       ^
a.cc:17:38: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   17 |                 link[a] = find(link[a]);
      |                                      ^
a.cc:17:31: error: no matching function for call to 'find(int (&)(const char*, const char*) noexcept)'
   17 |                 link[a] = find(link[a]);
      |                           ~~~~^~~~~~~~~
a.cc:13:5: note: candidate: 'int find(int)' (near match)
   13 | int find(int a){
      |     ^~~~
a.cc:13:5: note:   conversion of argument 1 would be ill-formed:
a.cc:17:38: error: invalid conversion from 'int (*)(const char*, const char*) noexcept' to 'int' [-fpermissive]
   17 |                 link[a] = find(link[a]);
      |                                ~~~~~~^
      |                                      |
      |                                      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:18:30: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   18 |                 return link[a];
      |                              ^
a.cc:18:30: error: invalid conversion from 'int (*)(const char*, const char*) noexcept' to 'int' [-fpermissive]
   18 |                 return link[a];
      |                              ^
      |                              |
      |                              int (*)(const char*, const char*) noexcept
a.cc: In function 'void unite(int, int)':
a.cc:26:13: error: reference to 'size' is ambiguous
   26 |         if (size[a] < size[b]) swap(a,b);
      |             ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:11:16: note:                 'int size [200005]'
   11 | int link[MAX], size[MAX];
      |                ^~~~
a.cc:26:23: error: reference to 'size' is ambiguous
   26 |         if (size[a] < size[b]) swap(a,b);
      |                       ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:11:16: note:                 'int size [200005]'
   11 | int link[MAX], size[MAX];
      |                ^~~~
a.cc:27:9: error: reference to 'size' is ambiguous
   27 |         size[a] += size[b];
      |         ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:11:16: note:                 'int size [200005]'
   11 | int link[MAX], size[MAX];
      |                ^~~~
a.cc:27:20: error: reference to 'size' is ambiguous
   27 |         size[a] += size[b];
      |                    ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:11:16: note:                 'int size [200005]'
   11 | int link[MAX], size[MAX];
      |                ^~~~
a.cc:28:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   28 |         link[b] = a;
      |               ^
a.cc:28:17: error: assignment of read-only location '*(link + ((sizetype)b))'
   28 |         link[b] = a;
      |         ~~~~~~~~^~~
a.cc: In function 'int main()':
a.cc:39:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   39 |         link[i] = i;
      |               ^
a.cc:39:17: error: assignment of read-only location '*(link + ((sizetype)i))'
   39 |         link[i] = i;
      |         ~~~~~~~~^~~
a.cc:40:9: error: reference to 'size' is ambiguous
   40 |         size[i] = 1;
      |         ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:11:16: note:                 'int size [200005]'
   11 | int link[MAX], size[MAX];
      |                ^~~~