/* Perform offline and query on the set, sort the query side in ascending order, and sort the query side in ascending order. For query X, the answer is to ask about the value of the X-1 plus ask about the L1 of the X-1 and ask about the edge merging between the L2 of X to bring the value to an edge between L1 and L2 if the endpoint U, V is ignored in a collection, otherwise, the new path is the size of the set where u is located multiplied by the size of the set where v is located */# include <iostream> # include <cstdio> # include <cstring> # include <cmath> # include <algorithm> # include <queue> # include <vector> # include <stack> # include <map> using namespace STD; const int M = 50009; const int n = 10009; struct edge {int U, V, W;} edge [m]; bool CMP (edge a, edge B) {return. W <B. W ;} Struct que {int num, Val;} Qu [N]; bool cmp2 (que a, que B) {return. val <B. val;} int n, m, Q; int Fa [N], Heav [N]; int ans [N]; void Init () {for (INT I = 0; I <m; I ++) {scanf ("% d", & edge [I]. u, & edge [I]. v, & edge [I]. w) ;}} int find (int x) {return Fa [x] = x? X: Fa [x] = find (Fa [x]);} int Union (int x, int y) {If (heav [x]> heav [y]) {Fa [y] = x; heav [x] + = heav [y];} else {Fa [x] = y; heav [y] + = heav [x] ;}} void solve () {for (INT I = 1; I <= N; I ++) {Fa [I] = I; heav [I] = 1 ;}for (INT I = 1; I <= Q; I ++) {scanf ("% d ", & Qu [I]. val); qu [I]. num = I;} Sort (edge, edge + M, CMP); sort (qu + 1, Qu + q + 1, cmp2); Int J = 0; for (INT I = 1; I <= Q; I ++) {ans [Qu [I]. num] = ans [Qu [I-1]. num]; while (edge [J]. W <= Qu [I]. val & J <m) {Int x = find (edge [J]. U); int y = find (edge [J]. V); If (X! = Y) {ans [Qu [I]. num] + = heav [x] * heav [y]; // cout <Qu [I]. num <"#" <ans [Qu [I]. num] <Endl; Union (x, y);} J ++; }}for (INT I = 1; I <= Q; I ++) {printf ("% d \ n", ANS [I]) ;}} int main () {While (scanf ("% d", & N, & M, & Q )! = EOF) {Init (); solve ();} return 0 ;}