Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using E = pair<int, int>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9 + 7;

int visit[100];
vector<vector<int>> G;

int dfs(int n, int m){
  visit[n] = 1;
  if(G[n].size() % 2 == 1){
    ++m;
  }
  for(int i : G[n]){
    if(!visit[i]){
      m = dfs(i,m);
    };
  }
  return m;
}

int main(void){
  int n;
  vector< P > p;
  cin >> n;
  for(int i = 0;i < n;++i){
    int x,y;
    cin >> x >> y;
    p.push_back(P(x,y));
  }
  G.clear();G.resize(n);
  for(int i = 0;i < n;++i){
    for(int j = i+1;j < n;++j){
      if(p[i].first != p[j].first &&
         p[i].second != p[j].second){
        G[i].push_back(j);
        G[j].push_back(i);
      }
    }
  }
  fill(visit,visit+100,0);
  int res = 0;
  for(int i = 0;i < n;++i){
    if(!visit[i]){
      ++res;
      int m = dfs(i);
      if(m % 2 == 1)++res;
    }
  }
  cout << res << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int dfs(int, int)':
a.cc:13:3: error: reference to 'visit' is ambiguous
   13 |   visit[n] = 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:9:5: note:                 'int visit [100]'
    9 | int visit[100];
      |     ^~~~~
a.cc:18:9: error: reference to 'visit' is ambiguous
   18 |     if(!visit[i]){
      |         ^~~~~
/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:9:5: note:                 'int visit [100]'
    9 | int visit[100];
      |     ^~~~~
a.cc: In function 'int main()':
a.cc:44:8: error: reference to 'visit' is ambiguous
   44 |   fill(visit,visit+100,0);
      |        ^~~~~
/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:9:5: note:                 'int visit [100]'
    9 | int visit[100];
      |     ^~~~~
a.cc:44:14: error: reference to 'visit' is ambiguous
   44 |   fill(visit,visit+100,0);
      |              ^~~~~
/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:9:5: note:                 'int visit [100]'
    9 | int visit[100];
      |     ^~~~~
a.cc:47:9: error: reference to 'visit' is ambiguous
   47 |     if(!visit[i]){
      |         ^~~~~
/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:9:5: note:                 'int visit [100]'
    9 | int visit[100];
      |     ^~~~~
a.cc:49:18: error: too few arguments to function 'int dfs(int, int)'
   49 |       int m = dfs(i);
      |               ~~~^~~
a.cc:12:5: note: declared here
   12 | int dfs(int n, int m){
      |     ^~~