Language: C++

#include<bits/stdc++.h>
using namespace std;
bool visit[100010];
struct edge{
	int to;
	int next;
}e[100010];
int cnt=1;
int head[100010];
void add_edge(int u,int v)
{
	e[cnt].to=v;
	e[cnt].next=head[u];
	head[u]=cnt;
	cnt++;
}
vector<int> v[100010];
int n;
void dfs(int node)
{
    visit[node]=true;
    for(int i=0;i<v[node].size();i++)
    {
    	if(visit[v[node][i]]==false)
            dfs(v[node][i]);
    }
}
int main()
{
    int m,k,a,b;
    cin>>n>>m;
    for(int i=0;i<m;i++)
	{
        cin>>a>>b;
    	v[a].push_back(b);
    	v[b].push_back(a);
    }
    memset(visit,0,sizeof(visit));
    int block=0;
    for(int j=1;j<=n;j++)
	{
        if(visit[j]==false)
		{
            dfs(j);
            block++;
        }
    } 
    cout<<block-1<<endl; 
    return 0;
}


Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:21:5: error: reference to 'visit' is ambiguous
   21 |     visit[node]=true;
      |     ^~~~~
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:3:6: note:                 'bool visit [100010]'
    3 | bool visit[100010];
      |      ^~~~~
a.cc:24:12: error: reference to 'visit' is ambiguous
   24 |         if(visit[v[node][i]]==false)
      |            ^~~~~
/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:3:6: note:                 'bool visit [100010]'
    3 | bool visit[100010];
      |      ^~~~~
a.cc: In function 'int main()':
a.cc:38:12: error: reference to 'visit' is ambiguous
   38 |     memset(visit,0,sizeof(visit));
      |            ^~~~~
/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:3:6: note:                 'bool visit [100010]'
    3 | bool visit[100010];
      |      ^~~~~
a.cc:38:27: error: reference to 'visit' is ambiguous
   38 |     memset(visit,0,sizeof(visit));
      |                           ^~~~~
/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:3:6: note:                 'bool visit [100010]'
    3 | bool visit[100010];
      |      ^~~~~
a.cc:42:12: error: reference to 'visit' is ambiguous
   42 |         if(visit[j]==false)
      |            ^~~~~
/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:3:6: note:                 'bool visit [100010]'
    3 | bool visit[100010];
      |      ^~~~~