func_code_string: #include <bits/stdc++.h>   const int INF = 1e9;   using namespace std;   void dfs(int v, int p, vector<vector<int> > &graph, vector<int> &sz) {     sz[v] = 1;     for (auto u : graph[v])       if (u != p) {         dfs(u, v, graph, sz);         sz[v] += sz[u];       }   }   void dfs(int v, int p, vector<vector<int> > &graph, vector<int> &c, int C) {     c[v] = C;     for (auto u : graph[v])       if (u != p) {         dfs(u, v, graph, c, C);       }   }   signed main() {     int n;     cin >> n;     vector<vector<int> > graph(n);     for (int i = 0; i < n - 1; i++) {       int a, b;       cin >> a >> b;       a--, b--;       graph[a].push_back(b);       graph[b].push_back(a);     }     vector<int> sz(n);     dfs(0, 0, graph, sz);     vector<int> cen;     long long ans = 0;     for (int i = 0; i < n; i++) {       if ((n - sz[i]) * 2 <= n) {         int t = 1;         for (auto u : graph[i]) {           if (sz[u] < sz[i]) {             if (2 * sz[u] <= n) continue;             t = 0;           }         }         if (t) cen.push_back(i);       }     }     for (int i = 0; i < n; i++) {       ans += 2 * min(sz[i], n - sz[i]);     }     cout << ans <<   n ;     if (cen.size() == 2) {       int v = cen[0], u = cen[1];       vector<int> c(n);       dfs(v, u, graph, c, 0);       dfs(u, v, graph, c, 1);       vector<int> p0, p1;       for (int i = 0; i < n; i++) {         if (c[i] == 0) p0.push_back(i);         if (c[i] == 1) p1.push_back(i);       }       vector<int> ans(n);       for (int i = 0; i < n / 2; i++) {         ans[p0[i]] = p1[i];         ans[p1[i]] = p0[i];       }       for (int i = 0; i < n; i++) {         cout << ans[i] + 1 <<    ;       }       return 0;     } else {       dfs(cen[0], cen[0], graph, sz);       int C = 0, idC = 0;       vector<int> c(n);       c[cen[0]] = -1;       int maxsz = 0;       for (auto u : graph[cen[0]]) {         dfs(u, cen[0], graph, c, C);         maxsz = max(maxsz, sz[u]);         if (maxsz == sz[u]) idC = C;         C++;       }       vector<pair<int, int> > q;       for (int i = 0; i < n; i++) {         if (i != cen[0] && c[i] != idC) q.push_back({c[i], i});       }       for (int i = 0; i < n; i++) {         if (i != cen[0] && c[i] == idC) q.push_back({INF, i});       }       q.push_back({INF + 1, cen[0]});       sort((q).begin(), (q).end());       vector<int> ans(n);       for (int i = 0; i < n; i++) {         ans[q[i].second] = q[(i + maxsz) % q.size()].second;       }       for (int i = 0; i < n; i++) {         assert(c[ans[i]] != c[i]);         cout << ans[i] + 1 <<    ;       }     }   }   