Language: C++

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<double, double> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

const ll mod = 1000000007;
ll n, m;
vector<vector<int>> g;
vector<P> dp;
vector<bool> visit;

P dfs(int current, int block) {
	if (visit[current]) {
		return dp[current];
	}
	vector<P> path;
	const int c = g[current].size();
	for (int next : g[current]) {
		path.push_back(dfs(next, block));
	}
	double zero = 0;
	double one = 0;
	for (auto p : path) {
		zero += p.first;
		one += p.second;
	}
	double all = zero;
	zero /= c;
	zero += 1;
	one /= c;
	one += 1;
	double cut = INF;
	if (c > 1 && current == block) {
		for (auto p : path) {
			cut = min(cut, all - (p.first));
		}
		cut /= (c - 1);
		cut += 1;
	}
	dp[current] = { zero, min(cut, one) };
	visit[current] = true;
	return dp[current];
}

int main() {
	cin >> n >> m;
	g.resize(n);
	rep(i, m) {
		int s, t;
		cin >> s >> t;
		s--; t--;
		g[s].push_back(t);
	}
	double ans = INF;
	for (int block = 0; block < n - 1; block++) {
		dp.assign(n, P(INF, INF));
		visit.assign(n, false);
		dp[n - 1] = { 0,0 };
		visit[n - 1] = true;
		for (int i = n - 2; i >= 0; i--) {
			dfs(i, block);
		}
		ans = min(ans, min(dp[0].first, dp[0].second));
	}
	cout << setprecision(10) << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'P dfs(int, int)':
a.cc:28:13: error: reference to 'visit' is ambiguous
   28 |         if (visit[current]) {
      |             ^~~~~
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:25:14: note:                 'std::vector<bool> visit'
   25 | vector<bool> visit;
      |              ^~~~~
a.cc:56:9: error: reference to 'visit' is ambiguous
   56 |         visit[current] = 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:25:14: note:                 'std::vector<bool> visit'
   25 | vector<bool> visit;
      |              ^~~~~
a.cc: In function 'int main()':
a.cc:72:17: error: reference to 'visit' is ambiguous
   72 |                 visit.assign(n, 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:25:14: note:                 'std::vector<bool> visit'
   25 | vector<bool> visit;
      |              ^~~~~
a.cc:74:17: error: reference to 'visit' is ambiguous
   74 |                 visit[n - 1] = 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:25:14: note:                 'std::vector<bool> visit'
   25 | vector<bool> visit;
      |              ^~~~~