Language: C++


#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int ll
#define vi vector<int>
#define vb vector<bool>
#define vvb vector<vb >
#define pii pair<int,int>
#define ss second
#define ff first
#define vpii vector<pii>
#define vvi vector<vi >
#define vs vector<string>
#define vvs vector<vs >
#define pqi priority_queue <int>
#define minpqi priority_queue <int, vector<int>, greater<int> >
#define all(x) x.begin(),x.end()
#define mii map<int,int>
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define per1(i,n) for(ll i=n;i>0;i--)
#define repeat(i,start,n) for(ll i=start;i<n;i++)
#define inp(arr,n) ll arr[n];rep(i,n){ cin>>arr[i];}
#define inp1(arr,n) ll arr[n+1];rep1(i,n){ cin>>arr[i];}
#define inp2d(arr,n,m) ll arr[n][m];rep(i,n)rep(j,m)cin>>arr[i][j];
#define inpg(adj,m) rep(i,m){int a,b;cin>>a>>b;adj[a].pb(b);adj[b].pb(a);}
#define print(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" ";}
#define print1(a,n) for(ll i=1;i<=n;i++){ cout<<a[i]<<endl;}
#define mod 1000000007
#define maxx 1000000000000000000
#define PI 3.141592653589793238462643383279
#define mmax(a,b,c) max(a,max(b,c))
#define mmin(a,b,c) min(a,min(b,c))
#define init(arr,a) memset(arr,a,sizeof(arr))
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element

//------------------------------------Code Starts here------------------------------------//
int visit[200001];
vi v[200001];
int ans,sz[200001];
void dfs(int node,int par)
{	ans++;
	visit[node]=1;
	//sz[node]=1;
	for(int i=0;i<(int)v[node].size();i++)
	{int child=v[node][i];
		if(child!=par)
			{ dfs(child,node);
			//sz[node]+=sz[it];
			}
	}
	//ans++;

}
main()
{
	int n,m;
	set<int>s;
	cin>>n>>m;
	for0(i,m)
	{
		int x,y;
		cin>>x>>y;
		int sz1=s.size();
		s.insert(x);
		s.insert(y);
		if((int)s.size()>sz1)
		{v[x].pb(y);
		v[y].pb(x);}
	}int sum=0;

	int cnt=0;
	for1(i,n)
	{
		if(visit[i]==0)
		{dfs(i,-1);cnt=max(ans,cnt);ans=0;}
	}
	cout<<cnt;
}


Compiler output:
a.cc: In function 'void dfs(long long int, long long int)':
a.cc:54:9: error: reference to 'visit' is ambiguous
   54 |         visit[node]=1;
      |         ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:2:
/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:49:5: note:                 'long long int visit [200001]'
   49 | int visit[200001];
      |     ^~~~~
a.cc: At global scope:
a.cc:66:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   66 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:86:20: error: reference to 'visit' is ambiguous
   86 |                 if(visit[i]==0)
      |                    ^~~~~
/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:49:5: note:                 'long long int visit [200001]'
   49 | int visit[200001];
      |     ^~~~~