Language: C++

#include <bits/stdc++.h>
using namespace std;

const int MAX = 300000;
int parent[MAX], hol[MAX], size[MAX];

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

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

int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		parent[i] = i;
		hol[i] = 1;
		size[i] = 1;
	}
	while (m--) {
		int a, b;
		cin >> a >> b;
		merge(a, b);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans = max(size[find(i)], ans);
	}
	cout << ans;
	return 0;
}



















Compiler output:
a.cc: In function 'void merge(int, int)':
a.cc:29:9: error: reference to 'size' is ambiguous
   29 |         size[a] += size[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,
                 from a.cc: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:5:28: note:                 'int size [300000]'
    5 | int parent[MAX], hol[MAX], size[MAX];
      |                            ^~~~
a.cc:29:20: error: reference to 'size' is ambiguous
   29 |         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:5:28: note:                 'int size [300000]'
    5 | int parent[MAX], hol[MAX], size[MAX];
      |                            ^~~~
a.cc: In function 'int main()':
a.cc:38:17: error: reference to 'size' is ambiguous
   38 |                 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:5:28: note:                 'int size [300000]'
    5 | int parent[MAX], hol[MAX], size[MAX];
      |                            ^~~~
a.cc:47:27: error: reference to 'size' is ambiguous
   47 |                 ans = max(size[find(i)], ans);
      |                           ^~~~
/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:5:28: note:                 'int size [300000]'
    5 | int parent[MAX], hol[MAX], size[MAX];
      |                            ^~~~