Language: C++

#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define INF 0x7fffffff
#define LL_INF 0x7fffffffffffffff
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
bool visit[2000005];

int main(void) {
	int n, m; cin >> n >> m;
	vector<vector<int>> v(n+1);
	for(int i=0;i<m;i++) {
		int a, b;
		cin >> a >> b;
		v[a].pb(b);
		v[b].pb(a);
	}
	vector<int> ans;
	queue<int> Q;
	for(int i=1;i<=n;i++) {
		if(!visit[i]) {
			visit[i] = true;
			Q.push(i);
			int cmp = 1;
			while(!Q.empty()) {
				int f = Q.front(); Q.pop();
				for(int j : v[f]) {
					if(!visit[j]) {
						visit[j] = true;
						Q.push(j);
						cmp++;
					}
				}
			}
			ans.pb(cmp);
		}
	}
	int maxi = 0;
	for(int i : ans) maxi = max(maxi, i);
	cout << maxi << endl;
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:24:21: error: reference to 'visit' is ambiguous
   24 |                 if(!visit[i]) {
      |                     ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:10:6: note:                 'bool visit [2000005]'
   10 | bool visit[2000005];
      |      ^~~~~
a.cc:25:25: error: reference to 'visit' is ambiguous
   25 |                         visit[i] = true;
      |                         ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:10:6: note:                 'bool visit [2000005]'
   10 | bool visit[2000005];
      |      ^~~~~
a.cc:31:45: error: reference to 'visit' is ambiguous
   31 |                                         if(!visit[j]) {
      |                                             ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:10:6: note:                 'bool visit [2000005]'
   10 | bool visit[2000005];
      |      ^~~~~
a.cc:32:49: error: reference to 'visit' is ambiguous
   32 |                                                 visit[j] = true;
      |                                                 ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:10:6: note:                 'bool visit [2000005]'
   10 | bool visit[2000005];
      |      ^~~~~