func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 4e5 + 100;   vector<int> adj[N];   int n, sz[N];   int get(int cur, int fr) {     sz[cur] = 1;     int ret = 0;     for (auto v : adj[cur]) {       if (v == fr) continue;       ret |= get(v, cur);       sz[cur] += sz[v];     }     if (!ret && sz[cur] > n / 2) ret = cur;     return ret;   }   void dfs(int cur, int fr) {     sz[cur] = 1;     for (auto v : adj[cur]) {       if (v == fr) continue;       dfs(v, cur);       sz[cur] += sz[v];     }   }   bool can[N];   void solve(int cur, int fr, int mx) {     if (n - sz[cur] - mx <= n / 2) can[cur] = 1;     vector<int> pre(1, 0), suf(1, 0);     for (auto v : adj[cur])       if (v != fr) pre.push_back(max(pre.back(), sz[v]));     for (int i = int(adj[cur].size()) - 1; i >= 0; i--) {       int v = adj[cur][i];       if (v != fr) suf.push_back(max(suf.back(), sz[v]));     }     reverse(suf.begin(), suf.end());     int j = 0;     for (int i = 0; i < adj[cur].size(); ++i) {       int v = adj[cur][i];       if (v == fr) continue;       int nmx = max(pre[j], suf[j + 1]);       nmx = max(nmx, mx);       if (n - sz[v] <= n / 2) nmx = max(nmx, n - sz[v]);       solve(v, cur, nmx);       j++;     }   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n - 1; ++i) {       int u, v;       scanf( %d , &u), scanf( %d , &v);       u--, v--;       adj[u].push_back(v);       adj[v].push_back(u);     }     int root = get(0, 0);     dfs(root, root);     solve(root, root, 0);     for (int i = 0; i < n; ++i)       if (can[i])         printf( 1  );       else         printf( 0  );   }   