func_code_string: #include <bits/stdc++.h>   using namespace std;   const int inf = 1e9;   int n;   char s[20];   int ans[300100];   vector<int> dep[300100];   int G[300100][26], siz[300100], son[300100];   vector<int *> a;   void dfs(int o, int depth) {     dep[depth].push_back(o);     siz[o] = 1;     for (int i = 0; i < 26; ++i) {       if (G[o][i] == -1) continue;       dfs(G[o][i], depth + 1);       if (son[o] == -1 || siz[son[o]] < siz[G[o][i]]) {         son[o] = G[o][i];       }       siz[o] += siz[G[o][i]];     }   }   int DFS(int u, int v) {     int ret = 0;     for (int i = 0; i < 26; ++i) {       if (G[u][i] == -1) continue;       if (G[v][i] == -1) {         G[v][i] = G[u][i];         ret += siz[G[u][i]];         a.push_back(&G[v][i]);       } else {         ret += DFS(G[u][i], G[v][i]);       }     }     return ret;   }   int main() {     memset(G, -1, sizeof(G));     memset(son, -1, sizeof(son));     scanf( %d , &n);     for (int i = 1; i < n; ++i) {       int u, v;       scanf( %d%d%s , &u, &v, s);       G[u][s[0] -  a ] = v;     }     dfs(1, 0);     int tmp = 0;     for (int i = 0; i <= n; ++i) {       a.clear();       ans[i] += tmp;       for (auto &j : dep[i]) {         if (son[j] != -1) ans[i + 1] += siz[son[j]] - 1;         for (int k = 0; k < 26; ++k) {           if (G[j][k] == -1 || son[j] == G[j][k]) continue;           ans[i + 1] += DFS(G[j][k], son[j]);         }       }       for (auto &i : a) {         *i = -1;       }       tmp += (int)dep[i].size();     }     tmp = 1;     for (int i = 2; i <= n; ++i) {       if (ans[tmp] > ans[i]) {         tmp = i;       }     }     printf( %d n%d n , ans[tmp], tmp);     return 0;   }   