func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 4e5 + 5;   struct Edge {     int v, nxt;     Edge() {}     Edge(int _v, int _nxt) : v(_v), nxt(_nxt) {}   };   Edge E[MAXN * 2];   int head[MAXN], ans[MAXN], sub[MAXN], mxsub[MAXN];   int tot = 0, fuc, n, x, y;   void addedge(int u, int v) {     E[tot] = Edge(v, head[u]);     head[u] = tot++;   }   void dfs1(int now, int fa) {     sub[now] = 1;     mxsub[now] = 1;     int tmp = 1;     for (int i = head[now]; ~i; i = E[i].nxt) {       int v = E[i].v;       if (v != fa) {         dfs1(v, now);         sub[now] += sub[v];         mxsub[now] = max(mxsub[now], mxsub[v]);         tmp += sub[v];       }     }     if (tmp <= fuc) {       mxsub[now] = tmp;     }   }   void dfs2(int now, int fa, int subfa, int mxfa) {     int cnt = subfa > fuc;     int id;     if (cnt) {       id = -1;     }     int tmp = n;     int mx1, mx2;     int id1, id2;     mx1 = mx2 = -1;     for (int i = head[now]; ~i; i = E[i].nxt) {       int v = E[i].v;       if (v != fa) {         if (id1 == -1 || mx1 < mxsub[v]) {           mx2 = mx1;           id2 = id1;           mx1 = mxsub[v];           id1 = v;         } else if (id2 == -1 || mx2 < mxsub[v]) {           mx2 = mxsub[v];           id2 = v;         }       }     }     for (int i = head[now]; ~i; i = E[i].nxt) {       int v = E[i].v;       if (v != fa) {         dfs2(v, now, sub[now] - sub[v] + subfa,              max(tmp - sub[v] <= fuc ? tmp - sub[v] : 0,                  max(mxfa, id1 == v ? mx2 : mx1)));         if (sub[v] > fuc) {           cnt++;           id = v;         }       }     }     if (cnt > 1) {       ans[now] = 0;     } else if (cnt == 0) {       ans[now] = 1;     } else if (id != -1) {       ans[now] = (sub[id] - mxsub[id] <= fuc);     } else {       ans[now] = (subfa - mxfa <= fuc);     }   }   int main() {     memset(head, -1, sizeof(head));     scanf( %d , &n);     for (int i = 1; i < n; i++) {       scanf( %d%d , &x, &y);       addedge(x, y);       addedge(y, x);     }     fuc = n / 2;     dfs1(1, 1);     dfs2(1, 1, 0, 0);     for (int i = 1; i <= n; i++) {       printf( %d  , ans[i]);     }   }   