func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<int> g[100005];   int sz[100005], answer[100005];   long long ans = 0;   vector<int> spis;   void clears(int v, int pr) {     sz[v] = 1;     int pos = -1;     for (int i = 0; i < (int)g[v].size(); i++) {       int u = g[v][i];       if (u == pr)         pos = i;       else {         clears(u, v);         sz[v] += sz[u];       }     }     if (pos != -1) {       swap(g[v][pos], g[v].back());       g[v].pop_back();     }     return;   }   void dfs(int v, int len) {     ans += (long long)2 * len;     spis.push_back(v);     for (int i = 0; i < (int)g[v].size(); i++) {       int u = g[v][i];       dfs(u, len + 1);     }     return;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     for (int i = 1; i < n; i++) {       int u, v;       cin >> u >> v;       g[u].push_back(v), g[v].push_back(u);     }     clears(1, -1);     int cen = 1;     while (true) {       int mx = -1;       for (int i = 0; i < (int)g[cen].size(); i++) {         int u = g[cen][i];         if (2 * sz[u] > sz[cen]) mx = i;       }       if (mx == -1) break;       int newcen = g[cen][mx];       swap(g[cen][mx], g[cen].back());       g[cen].pop_back();       g[newcen].push_back(cen);       sz[cen] -= sz[newcen];       sz[newcen] += sz[cen];       cen = newcen;     }     dfs(cen, 0);     cout << ans <<   n ;     if (n % 2 == 0) {       for (int i = 0; i < n / 2; i++)         answer[spis[i]] = spis[i + n / 2], answer[spis[i + n / 2]] = spis[i];     } else {       for (int i = 1; i < n / 2; i++)         answer[spis[i]] = spis[i + n / 2], answer[spis[i + n / 2]] = spis[i];       answer[spis[0]] = spis[n / 2], answer[spis[n / 2]] = spis[n - 1],       answer[spis[n - 1]] = spis[0];     }     for (int i = 1; i <= n; i++) cout << answer[i] <<    ;     cout <<   n ;     return 0;   }   