func_code_string: #include <bits/stdc++.h>   using namespace std;   bool cmp(pair<long long int, char> p1, pair<long long int, char> p2) {     return p1.first > p2.first;   }   vector<vector<long long int> > graph;   vector<bool> vis;   vector<vector<long long int> > level;   vector<long long int> d, childp;   void dfs(long long int node, long long int prev) {     vis[node] = true;     d[node] = prev + 1;     long long int temp = 1, i;     long long int x = 0, k = 1;     for (i = 0; i < graph[node].size(); i++) {       if (vis[graph[node][i]] == false) {         dfs(graph[node][i], d[node]);         x += childp[graph[node][i]];       }     }     childp[node] = x + 1;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int n, i, p;     cin >> n;     long double ans[n + 1];     graph.resize(n + 1);     level.resize(n + 1);     vis.resize(n + 1);     d.resize(n + 1);     childp.resize(n + 1);     for (i = 1; i <= n; i++) {       vis[i] = false;       d[i] = 0;       ans[i] = 0.0;       childp[i] = 0;     }     for (i = 2; i <= n; i++) {       cin >> p;       graph[p].push_back(i);       graph[i].push_back(p);     }     dfs(1, 0);     for (i = 1; i <= n; i++)       printf( %0.8lf  , ((n - childp[i] - d[i] + 1) / 2.0) + d[i]);   }   