Language: C++

#include <bits/stdc++.h> // Include every standard library
using namespace std;
int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};
#define sqr(x) ((LL)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define ALLA(arr, sz) arr, arr + sz
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define TC(t) while (t--)
#define ms(s, n) memset(s, n, sizeof(s))
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define size(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed << setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vii;
typedef vector<vi> vvi;
const int MOD = (int)1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int)1e9;
const ll LINF = (ll)1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b)
{
    ll r;
    while (b)
    {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
inline ll fpow(ll n, ll k, int p = MOD)
{
    ll r = 1;
    for (; k; k >>= 1)
    {
        if (k & 1)
            r = r * n % p;
        n = n * n % p;
    }
    return r;
}
inline ll isqrt(ll k)
{
    ll r = sqrt(k) + 1;
    while (r * r > k)
        r--;
    return r;
}
inline ll icbrt(ll k)
{
    ll r = cbrt(k) + 1;
    while (r * r * r > k)
        r--;
    return r;
}
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
int modulo(int a, int b) { return (a % b + b) % b; }
#define db(x) cerr << #x << " = " << (x) << " ";

vi graph[100005];
vi visit(100005);
vi deg(100005); //deg[v]= no of edges going into node v. 
vi dist(1000005);

void dfs(int v) {
    visit[v] = 1;
    for (int a : graph[v]) {
        dist[a] = max(dist[a], dist[v] + 1);
        deg[a]--;
        if(deg[a]==0)
            dfs(a);
    }
}

int main()
{
    IOS;
    int n, m;
    scanf("%d%d", &n, &m);
    while (m--){
        int x,y;
        scanf("%d%d", &x, &y);
        graph[x].pb(y);
        deg[y]++;
    }
    for (int a = 1; a <=n; a++) {
        if (visit[a] == 0 && deg[a] == 0)
            dfs(a);
    }
    int res = 0;
    for (int a = 1; a <= n; a++)
        res = max(res, dist[a]);
    printf("%d", res);
}


Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:91:5: error: reference to 'visit' is ambiguous
   91 |     visit[v] = 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:86:4: note:                 'vi visit'
   86 | vi visit(100005);
      |    ^~~~~
a.cc: In function 'int main()':
a.cc:112:13: error: reference to 'visit' is ambiguous
  112 |         if (visit[a] == 0 && deg[a] == 0)
      |             ^~~~~
/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:86:4: note:                 'vi visit'
   86 | vi visit(100005);
      |    ^~~~~