Language: C++

/*       _________
        /|______/ \
        ||  _|_|\  |
        || |_|   | /
        ||    _ / |
        ||  _| \\  \    
        ||_|_|\ || |
        |/_|/ | /|_/
              /__/      Written by: Rishabh Roshan
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int            	long long
#define tree         	ped
#define integer        	int32_t
#define mod         	1000000007
#define vint        	vector<integer>
#define pint        	pair<integer, integer>
#define umint        	unordered_map<integer, integer>
#define mint        	map<integer, integer>
#define in(x)        	int x; cin>>x
#define setbits(x)    	__builtin_popcountll(x)
#define zerobits(x)    	__builtin_ctzll(x)
#define w(x)        	int x; cin>>x; while(x--)
#define sp(x, y)    	fixed<<setprecision(y)<<x
#define poll(x)        	x.front(); x.pop()
#define f(x)        	for(int i=0; i<x; i++)
#define endl         	'\n'
#define inf         	1e9 
#define order_set     	tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

//#include "functions.h"

void om_shree_ganeshaya_namah(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

vector<bool> visit;
vint dp;
unordered_map<int, vint> dict;

int dfs(int x){
	if(!dict[x].size())
		return 0;

	if(dp[x])
		return dp[x];

	int max=0;
	vint v = dict[x];
	for(auto i:v){
		int a = dfs(i);
		if(a>max)
			max = a;
	}
	dp[x] = max+1;
	return dp[x];
}

int32_t main(){
    
    om_shree_ganeshaya_namah();

    in(n);
    w(m){
    	in(x); in(y);
    	dict[x].push_back(y);
    }
    dp = vint(n+1);
    visit = vector<bool>(n+1, false);

    for(auto it:dict){

/*    	cout<<it.first<<" -> ";
    	for(auto i:it.second)
    		cout<<i<<" ";
    	cout<<endl;
*/
    	if(!visit[it.first]){
    		visit[it.first] = true;
    		int max=0;
    		for(auto i:it.second){
    			int a = dfs(i);
    			visit[i] = true;
    			if(a>max)
    				max = a;
    		}
    		dp[it.first] = max+1;
    	}
    }

//    f(n) cout<<visit[i+1]<<" ";
  //  cout<<endl;
    // print(dp);
    int ans = *max_element(dp.begin(), dp.end());
    cout<<ans;

}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:80:5: error: reference to 'visit' is ambiguous
   80 |     visit = vector<bool>(n+1, false);
      |     ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:11:
/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:48:14: note:                 'std::vector<bool> visit'
   48 | vector<bool> visit;
      |              ^~~~~
a.cc:89:13: error: reference to 'visit' is ambiguous
   89 |         if(!visit[it.first]){
      |             ^~~~~
/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:48:14: note:                 'std::vector<bool> visit'
   48 | vector<bool> visit;
      |              ^~~~~
a.cc:90:17: error: reference to 'visit' is ambiguous
   90 |                 visit[it.first] = 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:48:14: note:                 'std::vector<bool> visit'
   48 | vector<bool> visit;
      |              ^~~~~
a.cc:94:25: error: reference to 'visit' is ambiguous
   94 |                         visit[i] = 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:48:14: note:                 'std::vector<bool> visit'
   48 | vector<bool> visit;
      |              ^~~~~