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) {
   if(dp[u])return dp[u];
   visit[u]=true;
   for(int x: v[u]){
    dp[u]=max(dp[u],f(x)+1);
   }
   return dp[u];
}
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));
    int mx=-1;
    for(int i=1;i<=n;i++){
        mx=max(mx,f(i));
    }
    cout<<mx;
}


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:33:6: note:                 'bool visit [100005]'
   33 | bool visit[100005];
      |      ^~~~~
a.cc: In function 'int main()':
a.cc:53:12: error: reference to 'visit' is ambiguous
   53 |     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:53:31: error: reference to 'visit' is ambiguous
   53 |     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];
      |      ^~~~~