Language: C++

#include<bits/stdc++.h>
using namespace std;
vector<int> v[100010];
bool visit[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(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);
    }
    fill(visit,visit+100009,false);  
    int block=0;
    for(int j=1;j<=n;j++)
	{
        if(visit[j]==false)
		{
            dfs(j);
            block++;
        }
    } 
    cout<<block-2<<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:4:6: note:                 'bool visit [100010]'
    4 | bool visit[100010];
      |      ^~~~~
a.cc:10:12: error: reference to 'visit' is ambiguous
   10 |         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:4:6: note:                 'bool visit [100010]'
    4 | bool visit[100010];
      |      ^~~~~
a.cc: In function 'int main()':
a.cc:23:10: error: reference to 'visit' is ambiguous
   23 |     fill(visit,visit+100009,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:4:6: note:                 'bool visit [100010]'
    4 | bool visit[100010];
      |      ^~~~~
a.cc:23:16: error: reference to 'visit' is ambiguous
   23 |     fill(visit,visit+100009,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:4:6: note:                 'bool visit [100010]'
    4 | bool visit[100010];
      |      ^~~~~
a.cc:27:12: error: reference to 'visit' is ambiguous
   27 |         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:4:6: note:                 'bool visit [100010]'
    4 | bool visit[100010];
      |      ^~~~~