Language: C++

#include <bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define EPS 1e-9
#define INF  1e15 +1    /// 10^15 + 1
#define INF2 ((ll)1)<<63 /// 2^63
#define all(a)  a.begin(),a.end()
#define bit(i,j) ((i)&((ll)1<<j))
#define setbit(i,j) ((i)|((ll)1<<j))
#define forn(i,n) for(int i=0;i<n;i++)
#define fo(i,a,b) for(int i=a;i<b;i++)
#define dbg(x) cout << #x"=" << x << '\n';
#define dbg2(x,y) cout << #x"=" << x << " " << #y"=" << y << '\n';
#define dbg3(x,y,z) cout << #x"=" << x << " " << #y"=" << y << " " << #z"=" << z << '\n';
const int MOD = 1000000007;
const int mod = 998244353;
const int nala5 = 1e5 +5;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector < vi > vvi;
typedef vector < vll > vvll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;
typedef vector < pii > vpii;
typedef vector < pll > vpll;
typedef vector < vpii > vvpii;
typedef vector < vpll > vvpll;
typedef vector < set <int> > vsi;
typedef vector < set <ll> > vsll;

int n,m,a,b,res;
vvi adj;
int dp[nala5],visit[nala5], degree[nala5];

void dfs(int index){
    visit[index] = 1;
    for(int i=0;i<adj[index].size();i++){
        dp[adj[index][i]] = max(dp[adj[index][i]], dp[index] + 1);
        res = max(res,dp[adj[index][i]]);
        degree[adj[index][i]]--;
        if(!visit[adj[index][i]] && !degree[adj[index][i]]) dfs(adj[index][i]);
    }
}

int main(){
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
    cin>>n>>m;
    adj.resize(n);
    forn(i,m){
        cin>>a>>b;
        adj[a-1].pb(b-1);
        degree[b]=1;
    }
    forn(i,n){
        if(!visit[i] && !degree[i]){
            dfs(i);
        }
    }
    cout<<res+1<<'\n';
}	


Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:42:5: error: reference to 'visit' is ambiguous
   42 |     visit[index] = 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:39:15: note:                 'int visit [100005]'
   39 | int dp[nala5],visit[nala5], degree[nala5];
      |               ^~~~~
a.cc:47:13: error: reference to 'visit' is ambiguous
   47 |         if(!visit[adj[index][i]] && !degree[adj[index][i]]) dfs(adj[index][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:39:15: note:                 'int visit [100005]'
   39 | int dp[nala5],visit[nala5], degree[nala5];
      |               ^~~~~
a.cc: In function 'int main()':
a.cc:61:13: error: reference to 'visit' is ambiguous
   61 |         if(!visit[i] && !degree[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:39:15: note:                 'int visit [100005]'
   39 | int dp[nala5],visit[nala5], degree[nala5];
      |               ^~~~~