Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>	       vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)	           for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 1000000007;

struct graph {
	int size;
	vector<list<int>> adj;
	vi h;
	graph(int n) : size(n), adj(n), h(n) {}
	void addEdge(int a, int b) {
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
};

vb visit(1e5, false);
int dfs(graph& g, int u) {
	visit[u] = true;
	int ans = 0;
	bool good = true;
	each(v, g.adj[u]) {
		if (g.h[u] <= g.h[v]) good = false;
		if (visit[v]) continue;
		ans += dfs(g, v);
	}
	if (good) ans++;
	return ans;
}

int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

	int n, m;
	cin >> n >> m;
	graph g(n);
	loop(n) cin >> g.h[i];
	int a, b;
	loop(m) {
		cin >> a >> b;
		g.addEdge(a - 1, b - 1);
	}
	int ans = 0;
	loop(n) {
		if (!visit[i]) ans += dfs(g, i);
	}
	cout << ans << endl;
	return 0;
}



Compiler output:
a.cc: In function 'int dfs(graph&, int)':
a.cc:37:9: error: reference to 'visit' is ambiguous
   37 |         visit[u] = 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:35:4: note:                 'vb visit'
   35 | vb visit(1e5, false);
      |    ^~~~~
a.cc:42:21: error: reference to 'visit' is ambiguous
   42 |                 if (visit[v]) 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:35:4: note:                 'vb visit'
   35 | vb visit(1e5, false);
      |    ^~~~~
a.cc: In function 'int main()':
a.cc:63:22: error: reference to 'visit' is ambiguous
   63 |                 if (!visit[i]) ans += dfs(g, 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:35:4: note:                 'vb visit'
   35 | vb visit(1e5, false);
      |    ^~~~~