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 |-------'
//              '--------------'
vector<int>v[100005];
int dp[100005];
bool visit[100005];
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);
    }
    memset(visit,false,sizeof(visit));
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++){
        if(!visit[i])f(i);
    }
    cout<<*max_element(dp,dp+n+1);
}


Compiler output:
a.cc: In function 'int f(int)':
a.cc:35:4: error: reference to 'visit' is ambiguous
   35 |    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:33:6: note:                 'bool visit [100005]'
   33 | bool visit[100005];
      |      ^~~~~
a.cc:37:9: error: reference to 'visit' is ambiguous
   37 |     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:33:6: note:                 'bool visit [100005]'
   33 | bool visit[100005];
      |      ^~~~~
a.cc:40:1: warning: no return statement in function returning non-void [-Wreturn-type]
   40 | }
      | ^
a.cc: In function 'int main()':
a.cc:52:12: error: reference to 'visit' is ambiguous
   52 |     memset(visit,false,sizeof(visit));
      |            ^~~~~
/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:33:6: note:                 'bool visit [100005]'
   33 | bool visit[100005];
      |      ^~~~~
a.cc:52:31: error: reference to 'visit' is ambiguous
   52 |     memset(visit,false,sizeof(visit));
      |                               ^~~~~
/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:33:6: note:                 'bool visit [100005]'
   33 | bool visit[100005];
      |      ^~~~~
a.cc:55:13: error: reference to 'visit' is ambiguous
   55 |         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:33:6: note:                 'bool visit [100005]'
   33 | bool visit[100005];
      |      ^~~~~