Language: C++

#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int n,m;
vector<int>a;
vector<int>b;
vector<vector<bool>>g;
vector<bool>visit;

void dfs(int v) {
    if(visit[v]) return;
    visit[v] = true;
    rep(nv,n) {
        if(g[v][nv]) {
            dfs(nv);
        }
    }
}
int main() {
    cin >> n >> m;
    a.resize(m);
    b.resize(m);
    g.assign(n,vector<bool>(n,false));
    visit.resize(n);
    int ans = 0;
    rep(i,m) {
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
        g[a[i]][b[i]] = true;
        g[b[i]][a[i]] = true;
    }
    rep(i,m) {
        rep(j,n) visit[j] = false;
        g[a[i]][b[i]] = false;
        g[b[i]][a[i]] = false;
        dfs(0);
        bool connected = true;
        rep(j,n) if(!(visit[j])) connected = false;
        if(!connected) ans++;
        g[a[i]][b[i]] = true;
        g[b[i]][a[i]] = true;
    }
    cout << ans << endl;
}






Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:16:8: error: reference to 'visit' is ambiguous
   16 |     if(visit[v]) return;
      |        ^~~~~
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:13:13: note:                 'std::vector<bool> visit'
   13 | vector<bool>visit;
      |             ^~~~~
a.cc:17:5: error: reference to 'visit' is ambiguous
   17 |     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:13:13: note:                 'std::vector<bool> visit'
   13 | vector<bool>visit;
      |             ^~~~~
a.cc: In function 'int main()':
a.cc:29:5: error: reference to 'visit' is ambiguous
   29 |     visit.resize(n);
      |     ^~~~~
/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:13:13: note:                 'std::vector<bool> visit'
   13 | vector<bool>visit;
      |             ^~~~~
a.cc:38:18: error: reference to 'visit' is ambiguous
   38 |         rep(j,n) 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:13:13: note:                 'std::vector<bool> visit'
   13 | vector<bool>visit;
      |             ^~~~~
a.cc:43:23: error: reference to 'visit' is ambiguous
   43 |         rep(j,n) if(!(visit[j])) connected = 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:13:13: note:                 'std::vector<bool> visit'
   13 | vector<bool>visit;
      |             ^~~~~