func_code_string: #include <bits/stdc++.h>   using namespace std;   pair<int, int> V[300300][30];   int Lar[300300];   vector<int> Map[300300];   struct tree {     tree *L[27];     tree() {       for (int i = 0; i < 27; i++) L[i] = NULL;     }   } root, *point, *point2;   int mm[300300], C[300300], depht[300300];   int MAX = 1;   tree *Pos[300300];   void dfs(int x) {     tree *ant = point;     C[x] = 1;     mm[x] = -1;     Pos[x] = point;     pair<int, int> *p;     for (int i = 0; i < Lar[x]; i++) {       p = &V[x][i];       if (point->L[p->second] == NULL) {         point->L[p->second] = new tree;         point = point->L[p->second];       } else {         point = point->L[p->second];       }       depht[p->first] = depht[x] + 1;       if (depht[p->first] > MAX) MAX = depht[p->first];       dfs(p->first);       C[x] += C[p->first];       if (mm[x] == -1) {         mm[x] = p->first;       } else if (C[p->first] > C[mm[x]]) {         mm[x] = p->first;       }       point = ant;     }     Map[depht[x]].push_back(x);   }   bool flag;   int Nodo;   void dfs2(int y) {     bool aflag = flag;     tree *ap2 = point2;     tree *ap1 = point;     pair<int, int> *p;     for (int i = 0; i < Lar[y]; i++) {       p = &V[y][i];       if (flag) {         if (point2->L[p->second] != NULL) {           point2 = point2->L[p->second];         } else {           flag = false;         }       }       if (point->L[p->second] != NULL) {         point = point->L[p->second];       } else {         point->L[p->second] = new tree;         point = point->L[p->second];         if (!flag) Nodo++;       }       dfs2(p->first);       point2 = ap2;       point = ap1;       flag = aflag;     }     flag = aflag;   }   int Sol[300300];   int main() {     int N, x, y;     char l[5];     scanf( %d , &N);     for (int i = 1; i < N; i++) {       scanf( %d%d%s , &x, &y, l);       V[x][Lar[x]] = pair<int, int>(y, l[0] -  a );       Lar[x]++;     }     depht[1] = 1;     point = &root;     Pos[1] = point;     dfs(1);     int X, Y;     for (int i = 1; i < MAX; i++) {       Sol[i] = 0;       for (vector<int>::iterator p = Map[i].begin(); p != Map[i].end(); p++) {         X = *p;         if (Lar[X] == 1) {           Sol[i]++;           continue;         } else if (Lar[X] == 0) {           continue;         }         tree *ante;         point = ante = new tree;         Nodo = C[mm[X]];         pair<int, int> *q;         for (int i = 0; i < Lar[X]; i++) {           q = &V[X][i];           Y = q->first;           if (Y != mm[X]) {             point2 = Pos[mm[X]];             flag = true;             dfs2(Y);             point = ante;           }         }         Sol[i] += (C[X]) - Nodo;       }     }     int XSol = 0;     for (int i = 1; i < MAX; i++) {       if (Sol[XSol] < Sol[i]) {         XSol = i;       }     }     printf( %d n%d n , N - Sol[XSol], XSol);     return 0;   }   