func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1000000 + 5;   int n, par[N], mx1[N], mx2[N], ans[N];   int main() {     scanf( %d , &n);     par[1] = mx1[1] = mx2[1] = ans[1] = 0;     for (int i = 2; i <= n + 1; i++) {       scanf( %d , &par[i]);       int v = i, val;       ans[i] = mx1[i] = mx2[i] = 0;       while (v > 0) {         val = max(mx1[v], mx2[v] + 1);         if (val <= ans[v]) break;         ans[v] = val;         if (mx1[par[v]] < val)           mx1[par[v]] = val;         else if (mx2[par[v]] < val)           mx2[par[v]] = val;         v = par[v];       }       printf( %d  , max(mx1[1], mx2[1]));     }     return 0;   }   