func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 5000 + 10;   bitset<MAXN> kna;   vector<int> G[MAXN];   int n, a, b, c, d, p[MAXN], sze[MAXN];   bool vis[MAXN];   bool check(int a, int b) {     memset(vis, 0, sizeof(vis));     kna.reset();     kna.flip(0);     for (int u = a; p[u]; u = p[u]) vis[u] = true;     for (int u = b; p[u]; u = p[u]) vis[u] = true;     for (int u = a; u; u = p[u])       for (auto i : G[u])         if (!vis[i]) {           kna |= kna << sze[i];         }     return kna.test(sze[1] / 2 - 1);   }   int main() {     scanf( %d%d%d%d%d , &n, &a, &b, &c, &d);     for (int i = 1; i <= n; i++) G[i].clear();     for (int i = 2; i <= n; i++) {       scanf( %d , &p[i]);       G[p[i]].push_back(i);     }     for (int u = n; u > 1; u--) {       sze[u] = max(sze[u], 1);       sze[p[u]] += sze[u];     }     if ((sze[1] % 2 == 0) && check(a, b) && check(c, d))       puts( YES n );     else       puts( NO n );     return 0;   }   