func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 400000 + 5;   vector<int> G[maxn];   int n;   int down[maxn], up[maxn], sz[maxn], par[maxn];   void dfs(int u, int fa) {     int len = G[u].size();     par[u] = fa;     sz[u] = 1;     for (int i = 0; i < len; i++) {       int v = G[u][i];       if (v == fa) continue;       dfs(v, u);       sz[u] += sz[v];     }   }   void dfs_down(int u, int fa) {     int len = G[u].size();     down[u] = (sz[u] <= n / 2) ? sz[u] : 0;     for (int i = 0; i < len; i++) {       int v = G[u][i];       if (v == fa) continue;       dfs_down(v, u);       down[u] = max(down[u], down[v]);     }   }   void dfs_up(int u, int val = 0, int fa = -1) {     if (val <= n / 2) {       up[u] = max(val, up[u]);     }     if (n - sz[u] <= n / 2) {       up[u] = max(n - sz[u], up[u]);     }     int len = G[u].size();     int m0 = 0, m1 = 0;     for (int i = 0; i < len; i++) {       int v = G[u][i];       if (v == fa) continue;       if (down[v] >= m0) {         m1 = m0;         m0 = down[v];       } else if (down[v] >= m1) {         m1 = down[v];       }     }     for (int i = 0; i < len; i++) {       int v = G[u][i];       if (v == fa) continue;       dfs_up(v, max(up[u], down[v] == m0 ? m1 : m0), u);     }   }   int ans[maxn];   int main() {     cin >> n;     for (int i = 0; i < n - 1; i++) {       int u, v;       scanf( %d%d , &u, &v);       G[u].push_back(v);       G[v].push_back(u);     }     dfs(1, -1);     dfs_down(1, -1);     dfs_up(1, 0, -1);     for (int u = 1; u <= n; u++) {       ans[u] = 1;       int len = G[u].size();       for (int j = 0; j < len; j++) {         int v = G[u][j];         if (v == par[u]) {           if (n - sz[u] - up[u] > n / 2) ans[u] = 0;         } else {           if (sz[v] - down[v] > n / 2) ans[u] = 0;         }       }     }     printf(  n );     for (int i = 1; i <= n; i++) {       printf( %d%c , ans[i], i == n ?   n  :    );     }     return 0;   }   