Language: C++

#include<bits/stdc++.h>
using namespace std;
bool visit[100010];
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:8:5: error: reference to 'visit' is ambiguous
    8 |     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:11:12: error: reference to 'visit' is ambiguous
   11 |         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:25:12: error: reference to 'visit' is ambiguous
   25 |     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:25:27: error: reference to 'visit' is ambiguous
   25 |     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:29:12: error: reference to 'visit' is ambiguous
   29 |         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];
      |      ^~~~~