func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 250000;   int n, dfn[N], size[N], cnt, Q;   struct node {     int tag, sum;   } t[N << 2];   vector<int> V[N];   void dfs(int x) {     dfn[x] = ++cnt;     size[x] = 1;     for (int i = 0, s = V[x].size(); i < s; i++)       dfs(V[x][i]), size[x] += size[V[x][i]];   }   void pushdown(int i, int l, int r) {     if (!t[i].tag) return;     int mid = (l + r) >> 1, ls = i << 1, rs = ls | 1;     t[ls].tag ^= 1;     t[rs].tag ^= 1;     t[ls].sum = (mid - l + 1 - t[ls].sum);     t[rs].sum = (r - mid - t[rs].sum);     t[i].tag = 0;   }   void update(int i, int l, int r, int x, int y) {     if (l >= x && r <= y) {       t[i].tag ^= 1;       t[i].sum = (r - l + 1 - t[i].sum);       return;     }     pushdown(i, l, r);     int mid = (l + r) >> 1;     if (mid >= x) update(i << 1, l, mid, x, y);     if (mid < y) update(i << 1 | 1, mid + 1, r, x, y);     t[i].sum = t[i << 1].sum + t[i << 1 | 1].sum;   }   int query(int i, int l, int r, int x, int y) {     if (l >= x && r <= y) return t[i].sum;     pushdown(i, l, r);     int mid = (l + r) >> 1, ans = 0;     if (mid >= x) ans += query(i << 1, l, mid, x, y);     if (mid < y) ans += query(i << 1 | 1, mid + 1, r, x, y);     return ans;   }   int main() {     scanf( %d , &n);     for (int i = 2; i <= n; i++) {       int x;       scanf( %d , &x);       V[x].push_back(i);     }     dfs(1);     for (int i = 1; i <= n; i++) {       char s = getchar();       while (s <  0  || s >  1 ) s = getchar();       if (s ==  1 ) update(1, 1, n, dfn[i], dfn[i]);     }     scanf( %d , &Q);     while (Q--) {       int x, opt;       char s = getchar();       while (!isalpha(s)) s = getchar();       if (s ==  g )         opt = 2;       else         opt = 1;       while (isalpha(s)) s = getchar();       scanf( %d , &x);       if (opt == 1)         update(1, 1, n, dfn[x], dfn[x] + size[x] - 1);       else         printf( %d n , query(1, 1, n, dfn[x], dfn[x] + size[x] - 1));     }   }   