func_code_string: #include <bits/stdc++.h>   using namespace std;   int n;   int sz0[400000];   vector<int> g[400000];   vector<int> c0[400000];   int centroid;   int sz[400000];   vector<int> cs[400000];   int ans[400000];   void dfs0(int x) {     sz0[x] = 1;     for (int y : g[x]) {       if (sz0[y] == 0) {         c0[x].push_back(y);         dfs0(y);         sz0[x] += sz0[y];       }     }   }   int findc(int x) {     for (int y : c0[x]) {       if (sz0[y] > n / 2) {         return findc(y);       }     }     return x;   }   void dfs1(int x) {     sz[x] = 1;     for (int y : g[x]) {       if (sz[y] == 0) {         cs[x].push_back(y);         dfs1(y);         sz[x] += sz[y];       }     }   }   bool cmp(int a, int b) { return sz[a] > sz[b]; }   void dfs2(int x, int s, int m) {     if (s - m <= n / 2) ans[x] = 1;     for (int y : cs[x]) {       int ss = s + sz[x] - sz[y];       dfs2(y, ss, m);     }   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n - 1; i++) {       int a, b;       scanf( %d%d , &a, &b);       a--;       b--;       g[a].push_back(b);       g[b].push_back(a);     }     dfs0(0);     centroid = findc(0);     dfs1(centroid);     ans[centroid] = 1;     if (cs[centroid].size() == 1) {       assert(n <= 2);       ans[0] = ans[1] = 1;     } else {       vector<int>& c = cs[centroid];       sort(c.begin(), c.end(), cmp);       dfs2(c[0], sz[centroid] - sz[c[0]], sz[c[1]]);       for (int i = 1; i < c.size(); i++)         dfs2(c[i], sz[centroid] - sz[c[i]], sz[c[0]]);       if (sz[c[0]] * 2 == n)         for (int i = 0; i < n; i++) ans[i] = 1;     }     for (int i = 0; i < n; i++) printf( %d  , ans[i]);     putchar(  n );   }   