func_code_string: #include <bits/stdc++.h>   using namespace std;   struct edge {     int x, y, d, r;     bool operator<(edge const &T) const { return d < T.d; }   };   int n, t, ed, x, y;   int v[100005], b[100005], p[100005], s[100005], l[100005], qd[100005 + 100005],       qn[100005 + 100005], qr[100005 + 100005];   long long int sum, mx, sz[100005], res[100005];   edge a[100005];   void bd(int x, int y, int r) {     qd[++ed] = y, qn[ed] = l[x], qr[ed] = r, l[x] = ed;   }   void precal(int x) {     sum += s[x];     v[x] = 1;     for (int i = l[x]; i; i = qn[i])       if (!v[qd[i]]) precal(qd[i]);   }   void dfs(int x, int y) {     sz[x] = s[x];     for (int i = l[x]; i; i = qn[i]) {       if (qd[i] == y) continue;       dfs(qd[i], x);       res[qr[i]] = (sum - sz[qd[i]]) * sz[qd[i]];       sz[x] += sz[qd[i]];     }   }   int find(int x) { return x == p[x] ? x : p[x] = find(p[x]); }   int main() {     scanf( %d , &n);     for (int i = (0); i < (n - 1); i++)       scanf( %d%d%d , &a[i].x, &a[i].y, &a[i].d), a[i].r = i + 1;     for (int i = (1); i <= (n); i++) p[i] = i, s[i] = 1;     sort(a, a + n - 1);     for (int i = 0, j = 0; i < n - 1; i = j) {       ed = t = 0;       while (j < n - 1 && a[i].d == a[j].d) {         b[t++] = x = find(a[j].x);         b[t++] = y = find(a[j].y);         bd(x, y, a[j].r), bd(y, x, a[j].r);         j++;       }       sort(b, b + t);       t = unique(b, b + t) - b;       for (int k = (0); k < (t); k++) v[b[k]] = 0;       for (int k = (0); k < (t); k++) {         if (v[b[k]]) continue;         sum = 0;         precal(b[k]);         dfs(b[k], -1);       }       for (int k = (0); k < (t); k++) l[b[k]] = 0;       for (int k = i; k < j; k++) {         x = find(a[k].x), y = find(a[k].y);         p[x] = y;         s[y] += s[x];       }     }     mx = 0;     for (int i = (1); i <= (n - 1); i++) mx = max(mx, res[i]);     sum = 0;     for (int i = (1); i <= (n - 1); i++) sum += res[i] == mx;     printf( %I64d %I64d n , mx << 1, sum);     for (int i = (1); i <= (n - 1); i++)       if (res[i] == mx) printf( %d  , i);     puts(  );     return 0;   }   