func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 200005;   int fa[maxn][20], d[maxn], n, p, q, ans, b, c;   int dist(int x, int y) {     int res = d[x] + d[y];     if (d[x] < d[y]) swap(x, y);     for (int j = 18; j >= 0; j--)       if (d[fa[x][j]] >= d[y]) x = fa[x][j];     if (x == y) return res - 2 * d[x];     for (int j = 18; j >= 0; j--)       if (fa[x][j] != fa[y][j]) x = fa[x][j], y = fa[y][j];     return res - 2 * d[fa[x][0]];   }   int main() {     scanf( %d , &n);     d[0] = -1;     p = q = 1;     for (int i = 2; i <= n; i++) {       scanf( %d , &fa[i][0]);       d[i] = d[fa[i][0]] + 1;       for (int j = 1; j <= 18; j++) fa[i][j] = fa[fa[i][j - 1]][j - 1];       b = dist(i, p);       c = dist(i, q);       if (b >= c && b >= ans)         ans = b, q = i;       else if (c >= b && c >= ans)         ans = c, p = i;       printf( %d  , ans);     }     return 0;   }   