Language: C++

#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl
#define MAX_N 100006
#define all(x) x.begin(),x.end()
typedef pair<int,int> P;
typedef pair<int,P> PP;

int n,m;
int k[100000];
int par[MAX_N];
int rank[MAX_N];
void init(int n)
{
	rep(i,n)
	{
		par[i]=i;
		rank[i]=0;
	}
}
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]++;
	}
}
bool same(int x,int y)
{
	return find(x)==find(y);
}
int hai[100000];
int main()
{
	
	cin>>n>>m;
	init(n);
	rep(i,n)
	{
		cin>>k[i];
		rep(j,k[i])
		{
			cin>>hai[j];
			hai[j]--;
		}
		rep(j,k[i]-1)
		{
			unite(hai[j],hai[j+1]);
		}
	}
	//rep(i,n)cout<<
	rep(i,n-1)
	{
		
		if(!same(i,i+1))
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'void init(int)':
a.cc:30:17: error: reference to 'rank' is ambiguous
   30 |                 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:24:5: note:                 'int rank [100006]'
   24 | int rank[MAX_N];
      |     ^~~~
a.cc: In function 'void unite(int, int)':
a.cc:43:12: error: reference to 'rank' is ambiguous
   43 |         if(rank[x]<rank[y])par[x]=y;
      |            ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:24:5: note:                 'int rank [100006]'
   24 | int rank[MAX_N];
      |     ^~~~
a.cc:43:20: error: reference to 'rank' is ambiguous
   43 |         if(rank[x]<rank[y])par[x]=y;
      |                    ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
 1437 |     struct rank
      |            ^~~~
a.cc:24:5: note:                 'int rank [100006]'
   24 | int rank[MAX_N];
      |     ^~~~
a.cc:46:20: error: reference to 'rank' is ambiguous
   46 |                 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:24:5: note:                 'int rank [100006]'
   24 | int rank[MAX_N];
      |     ^~~~
a.cc:46:29: error: reference to 'rank' is ambiguous
   46 |                 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:24:5: note:                 'int rank [100006]'
   24 | int rank[MAX_N];
      |     ^~~~
a.cc:46:37: error: reference to 'rank' is ambiguous
   46 |                 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:24:5: note:                 'int rank [100006]'
   24 | int rank[MAX_N];
      |     ^~~~