Language: C++

#include <bits/stdc++.h>
#define ll long long
using namespace std;

int visit[100005];
vector <int> route[100005];

void dfs(int v){
    visit[v]=1;
    for(int i:route[v]){
        if (visit[i]==1) continue;
        dfs(i);
    }
}

void testcase(){
    memset(visit,0,sizeof(visit));
    int n,m;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        route[a].push_back(b);
        route[b].push_back(a);
    }
    int c=0;
    for(int i=0;i<n;i++){
        if(visit[i]==1) continue;
        dfs(i);
        c++;
    }
    cout << c-1;

}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int q=1;
   // cin >> q;
    while(q--){
    testcase();
    }
    return 0;
}


Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:9:5: error: reference to 'visit' is ambiguous
    9 |     visit[v]=1;
      |     ^~~~~
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:5:5: note:                 'int visit [100005]'
    5 | int visit[100005];
      |     ^~~~~
a.cc:11:13: error: reference to 'visit' is ambiguous
   11 |         if (visit[i]==1) continue;
      |             ^~~~~
/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:5:5: note:                 'int visit [100005]'
    5 | int visit[100005];
      |     ^~~~~
a.cc: In function 'void testcase()':
a.cc:17:12: error: reference to 'visit' is ambiguous
   17 |     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:5:5: note:                 'int visit [100005]'
    5 | int visit[100005];
      |     ^~~~~
a.cc:17:27: error: reference to 'visit' is ambiguous
   17 |     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:5:5: note:                 'int visit [100005]'
    5 | int visit[100005];
      |     ^~~~~
a.cc:30:12: error: reference to 'visit' is ambiguous
   30 |         if(visit[i]==1) continue;
      |            ^~~~~
/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:5:5: note:                 'int visit [100005]'
    5 | int visit[100005];
      |     ^~~~~