Language: C++

//0321 部活動調査
//UF木
#include<bits/stdc++.h>
#define LL long long int
using namespace std;
LL bol[200010],r1[200010],r2[200010],club[100010],node[100010],size[100010];
int root(int x){
	if(x!=node[x]){
		node[x]=return root(node[x]);
	}
	else return x;
}
int main(void)
{
	LL i,j,n,m,k;
	cin>>n>>m>>k;
	for(i=0;i<k;i++) cin>>bol[i]>>r1[i]>>r2[i];
	for(i=0;i<n;i++) club[i]=0,node[i]=i,size[i]=1;
	for(i=0;i<k;i++) {
		int x,y,c,s;
		if(bol[i]==1) {
			x=r1[i],y=r2[i];
			x=root(x);
			y=root(y);
			if(club[x]!=0&&club[y]!=0&&club[x]!=club[y]) {
				cout<<i+1<<endl;
				break;
			}
			else if(club[x]!=0&&club[y]==0) club[y]=club[x];
			else if(club[x]==0&&club[y]!=0) club[x]=club[y];
			if(x!=y) {
				if(size[x]>size[y]) node[y]=x;
				else if(size[y]>size[x]) node[x]=y;
				else node[y]=x,size[x]++;
			}
		}
		else {
			s=r1[i],c=r2[i];
			s=root(s);
			if(club[s]==0) club[s]=c;
			else if(club[s]!=c) {
				cout<<i+1<<endl;
				break;
			}
		}
	}
	if(i==k) cout<<"0"<<endl;
}

Compiler output:
a.cc: In function 'int root(int)':
a.cc:9:25: error: expected primary-expression before 'return'
    9 |                 node[x]=return root(node[x]);
      |                         ^~~~~~
a.cc: In function 'int main()':
a.cc:18:46: error: reference to 'size' is ambiguous
   18 |         for(i=0;i<n;i++) club[i]=0,node[i]=i,size[i]=1;
      |                                              ^~~~
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,
                 from a.cc:3:
/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:6:64: note:                 'long long int size [100010]'
    6 | LL bol[200010],r1[200010],r2[200010],club[100010],node[100010],size[100010];
      |                                                                ^~~~
a.cc:32:36: error: reference to 'size' is ambiguous
   32 |                                 if(size[x]>size[y]) node[y]=x;
      |                                    ^~~~
/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:6:64: note:                 'long long int size [100010]'
    6 | LL bol[200010],r1[200010],r2[200010],club[100010],node[100010],size[100010];
      |                                                                ^~~~
a.cc:32:44: error: reference to 'size' is ambiguous
   32 |                                 if(size[x]>size[y]) node[y]=x;
      |                                            ^~~~
/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:6:64: note:                 'long long int size [100010]'
    6 | LL bol[200010],r1[200010],r2[200010],club[100010],node[100010],size[100010];
      |                                                                ^~~~
a.cc:33:41: error: reference to 'size' is ambiguous
   33 |                                 else if(size[y]>size[x]) node[x]=y;
      |                                         ^~~~
/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:6:64: note:                 'long long int size [100010]'
    6 | LL bol[200010],r1[200010],r2[200010],club[100010],node[100010],size[100010];
      |                                                                ^~~~
a.cc:33:49: error: reference to 'size' is ambiguous
   33 |                                 else if(size[y]>size[x]) node[x]=y;
      |                                                 ^~~~
/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:6:64: note:                 'long long int size [100010]'
    6 | LL bol[200010],r1[200010],r2[200010],club[100010],node[100010],size[100010];
      |                                                                ^~~~
a.cc:34:48: error: reference to 'size' is ambiguous
   34 |                                 else node[y]=x,size[x]++;
      |                                                ^~~~
/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:6:64: note:                 'long long int size [100010]'
    6 | LL bol[200010],r1[200010],r2[200010],club[100010],node[100010],size[100010];
      |                                                                ^~~~
a.cc: In function 'int root(int)':
a.cc:12:1: warning: control reaches end of non-void function [-Wreturn-type]
   12 | }
      | ^