func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 400010;   inline int max(int a, int b) { return a > b ? a : b; }   int head[maxn], cnt, sz[maxn], n, mx_sz, top[maxn], ans[maxn];   vector<int> vt;   struct ed {     int to, next;   } e[maxn * 2];   void ad(int x, int y) {     e[cnt] = (ed){y, head[x]};     head[x] = cnt++;     e[cnt] = (ed){x, head[y]};     head[y] = cnt++;   }   void get_vt(int u, int last) {     sz[u] = 1;     int mx = 0;     for (int k = head[u]; ~k; k = e[k].next) {       int v = e[k].to;       if (v != last) {         get_vt(v, u);         sz[u] += sz[v];         mx = max(mx, sz[v]);       }     }     mx = max(mx, n - sz[u]);     if (mx <= mx_sz) vt.push_back(u);   }   void dfs(int u, int last, int tp) {     sz[u] = 1, top[u] = tp;     for (int k = head[u]; ~k; k = e[k].next) {       int v = e[k].to;       if (v != last) {         dfs(v, u, tp);         sz[u] += sz[v];       }     }   }   void work(int u) {     ans[u] = 1;     memset(sz, 0, sizeof(sz));     int mx = 0, _mx = 0;     for (int k = head[u]; ~k; k = e[k].next) {       int v = e[k].to;       dfs(v, u, v);       if (sz[v] >= sz[mx])         _mx = mx, mx = v;       else if (sz[v] > sz[_mx])         _mx = v;     }     for (int i = 1; i <= n; i++) {       if (top[i] == mx)         ans[i] |= (n - sz[i] - sz[_mx] <= mx_sz);       else         ans[i] |= (n - sz[i] - sz[mx] <= mx_sz);     }   }   int main() {     while (~scanf( %d , &n)) {       cnt = 0;       mx_sz = n / 2;       vt.clear();       memset(sz, 0, sizeof(sz));       memset(ans, 0, sizeof(ans));       memset(head, -1, sizeof(head));       int u, v;       for (int i = 1; i < n; i++) {         scanf( %d%d , &u, &v);         ad(u, v);       }       get_vt(1, 0);       for (int i = 0; i < vt.size(); i++) work(vt[i]);       for (int i = 1; i <= n; i++) printf( %d  , ans[i]);     }     return 0;   }   