Language: C++

#include <iostream>
#include <bits/stdc++.h>

using namespace std;

vector<vector<int>> G(8,vector<int>(8));
vector<bool> visit(8,false);
int ans;
int n, m;

/*
目的: 頂点を受け取り, 条件を満たすかどうかを探索する. 何も返さない.
*/

void dfs(int v){
    
    bool allVisited = true;
    for (int i = 0; i < n; i++) if (i != v && !visit[i]) allVisited = false;
    
    if (allVisited){
        ans++;
        return;
    }
    
    visit[v] = true;
    
    for (auto p : G[v]){
        if (!visit[p]) dfs(p);
    }
    
    visit[v] = false;
}

int main(void){
    cin >> n >> m;
    
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    ans = 0;
    visit[0] = true;
    dfs(0);
    
    cout << ans << endl;
    return 0;
    
}


Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:18:48: error: reference to 'visit' is ambiguous
   18 |     for (int i = 0; i < n; i++) if (i != v && !visit[i]) allVisited = false;
      |                                                ^~~~~
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:7:14: note:                 'std::vector<bool> visit'
    7 | vector<bool> visit(8,false);
      |              ^~~~~
a.cc:25:5: error: reference to 'visit' is ambiguous
   25 |     visit[v] = true;
      |     ^~~~~
/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:7:14: note:                 'std::vector<bool> visit'
    7 | vector<bool> visit(8,false);
      |              ^~~~~
a.cc:28:14: error: reference to 'visit' is ambiguous
   28 |         if (!visit[p]) dfs(p);
      |              ^~~~~
/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:7:14: note:                 'std::vector<bool> visit'
    7 | vector<bool> visit(8,false);
      |              ^~~~~
a.cc:31:5: error: reference to 'visit' is ambiguous
   31 |     visit[v] = 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:7:14: note:                 'std::vector<bool> visit'
    7 | vector<bool> visit(8,false);
      |              ^~~~~
a.cc: In function 'int main()':
a.cc:46:5: error: reference to 'visit' is ambiguous
   46 |     visit[0] = true;
      |     ^~~~~
/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:7:14: note:                 'std::vector<bool> visit'
    7 | vector<bool> visit(8,false);
      |              ^~~~~