func_code_string: #include <bits/stdc++.h>   using namespace std;   const int INF = 2e9;   const long long BIG_INF = 1e18;   const long long MOD = 1e9 + 7;   const int maxn = 1e5 + 5;   vector<int> g[maxn];   int p[maxn], max_height, deep_v;   void dfs(int v, int height) {     if (height > max_height) {       max_height = height;       deep_v = v;     }     for (int j = 0; j < (int)g[v].size(); j++) {       int to = g[v][j];       dfs(to, height + 1);     }   }   void out(int v) {     if (v) out(p[v]);     ;     cout << v <<    ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     for (int i = 1; i < n; i++) {       int u;       cin >> u;       p[i] = u;       g[u].push_back(i);     }     dfs(0, 0);     vector<int> ans;     int v = deep_v;     while (1) {       while (v && (int)g[p[v]].size() == 1) v = p[v];       if (!v) break;       int par = p[v];       g[par].erase(find(g[par].begin(), g[par].end(), v));       int to = g[par][0];       ans.push_back(v);       g[to].push_back(v);       p[v] = to;     }     out(deep_v);     cout <<   n ;     reverse(ans.begin(), ans.end());     cout << (int)ans.size() <<   n ;     for (int i = 0; i < (int)ans.size(); i++) cout << ans[i] <<    ;     cout <<   n ;     return 0;   }   