func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 100010, maxs = 200010;   const int inf = 2000000000;   int n, m, ecnt;   pair<int, int> edges[maxs];   bool dat[maxn];   int c[maxn];   int pos[maxn], last[maxn], nowt;   vector<pair<int, int> > ga[maxn];   vector<int> weight[maxn];   void insertunit(int* c, int pos, int x) {     for (; pos <= n; pos += pos & (-pos)) c[pos] += x;   }   int querysum(int* c, int pos) {     int ans = 0;     for (; pos; pos -= pos & (-pos)) ans += c[pos];     return ans;   }   int lcaf[maxn][20], depth[maxn];   void dfs(int start = 1) {     pos[start] = ++nowt;     for (int i = 1; i < 20; i++) lcaf[start][i] = lcaf[lcaf[start][i - 1]][i - 1];     for (vector<pair<int, int> >::iterator it = ga[start].begin();          it != ga[start].end(); it++) {       if (it->first != lcaf[start][0]) {         lcaf[it->first][0] = start;         depth[it->first] = depth[start] + 1;         dfs(it->first);       }     }     last[start] = nowt;   }   int lca(int x, int y) {     if (depth[x] > depth[y]) swap(x, y);     for (int i = 19; i >= 0; i--)       if (lcaf[y][i] && depth[lcaf[y][i]] >= depth[x]) y = lcaf[y][i];     if (x == y) return x;     for (int i = 19; i >= 0; i--)       if (lcaf[x][i] != lcaf[y][i]) x = lcaf[x][i], y = lcaf[y][i];     return lcaf[x][0];   }   void insertpath(int x, int y) {     int u = lca(x, y);     insertunit(c, pos[x], 1);     insertunit(c, pos[y], 1);     insertunit(c, pos[u], -1);     if (depth[u]) insertunit(c, pos[lcaf[u][0]], -1);   }   int querynode(int x) { return querysum(c, last[x]) - querysum(c, pos[x] - 1); }   pair<int, int> f[maxs];   bool vis[maxs];   pair<int, int> getf(int en) {     if (ga[edges[en].first].size() == 1)       if (dat[edges[en].first])         return make_pair(0, edges[en].first);       else         return make_pair(-inf, -1);     if (vis[en]) return f[en];     vis[en] = true;     int st = edges[en].first;     int ed = edges[en].second;     int nowmin = -inf, cnt = 0, nowlca = -1;     if (dat[st]) {       nowmin = 0;       cnt = 1;       nowlca = st;     }     int p = 0;     for (vector<pair<int, int> >::iterator it = ga[st].begin();          it != ga[st].end(); it++, p++)       if (it->first != ed) {         pair<int, int> t = getf(it->second);         if (t.second == -1) continue;         t.first += weight[st][p];         if (t.first > nowmin) {           nowmin = t.first;           nowlca = t.second;           cnt = 1;         } else if (t.first == nowmin)           cnt++;       }     if (cnt > 1)       f[en] = make_pair(nowmin, st);     else if (cnt == 1)       f[en] = make_pair(nowmin, nowlca);     else       f[en] = make_pair(-inf, -1);     return f[en];   }   void processpath() {     for (int i = 1; i <= n; i++) {       if (dat[i]) {         int nowmin = -inf, cnt = 0, nowlca = -1, p = 0;         for (vector<pair<int, int> >::iterator it = ga[i].begin();              it != ga[i].end(); it++, p++) {           pair<int, int> t = getf(it->second);           if (t.second == -1) continue;           t.first += weight[i][p];           if (t.first > nowmin) {             nowmin = t.first;             nowlca = t.second;             cnt = 1;           } else if (t.first == nowmin) {             cnt++;           }         }         if (cnt == 1) insertpath(i, nowlca);       }     }   }   pair<int, int> getans() {     int nowmax = 0, cnt = 0;     for (int i = 1; i <= n; i++) {       if (dat[i]) continue;       int t = querynode(i);       if (t > nowmax) {         nowmax = t;         cnt = 1;       } else if (t == nowmax)         cnt++;     }     return make_pair(nowmax, cnt);   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < m; i++) {       int x;       scanf( %d , &x);       dat[x] = true;     }     for (int i = 1; i < n; i++) {       int x, y, w;       scanf( %d%d%d , &x, &y, &w);       edges[ecnt++] = make_pair(x, y);       edges[ecnt++] = make_pair(y, x);       ga[x].push_back(make_pair(y, ecnt - 1));       ga[y].push_back(make_pair(x, ecnt - 2));       weight[x].push_back(w);       weight[y].push_back(w);     }     dfs();     processpath();     pair<int, int> t = getans();     printf( %d %d n , t.first, t.second);     return 0;   }   