Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
#define MAX_N 100005
vector<int>v[MAX_N];
int dp[MAX_N];
bool visit[MAX_N];
int f(int u) {
   visit[u]=true;
   for(int i=0;i<v[u].size();i++){
    if(!visit[v[u][i]])f(v[u][i]);
    dp[u]=max(dp[u],dp[v[u][i]]+1);
   }
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
    }
    for(int i=1;i<=n;i++){
        if(!visit[i])f(i);
    }
    cout<<*max_element(dp,dp+MAX_N);
}


Compiler output:
a.cc: In function 'int f(int)':
a.cc:36:4: error: reference to 'visit' is ambiguous
   36 |    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:34:6: note:                 'bool visit [100005]'
   34 | bool visit[MAX_N];
      |      ^~~~~
a.cc:38:9: error: reference to 'visit' is ambiguous
   38 |     if(!visit[v[u][i]])f(v[u][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:34:6: note:                 'bool visit [100005]'
   34 | bool visit[MAX_N];
      |      ^~~~~
a.cc:41:1: warning: no return statement in function returning non-void [-Wreturn-type]
   41 | }
      | ^
a.cc: In function 'int main()':
a.cc:54:13: error: reference to 'visit' is ambiguous
   54 |         if(!visit[i])f(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:34:6: note:                 'bool visit [100005]'
   34 | bool visit[MAX_N];
      |      ^~~~~