![]() |
||||||||||
|
||||||||||
Tree chain problemTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2772 Accepted Submission(s): 885 Problem Description Coco has a tree, whose vertices are conveniently labeled by 1,2,…,n. There are m chain on the tree, Each chain has a certain weight. Coco would like to pick out some chains any two of which do not share common vertices. Find out the maximum sum of the weight Coco can pick Input The input consists of several test cases. The first line of input gives the number of test cases T (T<=10). For each tests: First line two positive integers n, m.(1<=n,m<=100000) The following (n - 1) lines contain 2 integers ai bi denoting an edge between vertices ai and bi (1≤ai,bi≤n), Next m lines each three numbers u, v and val(1≤u,v≤n,0<val<1000), represent the two end points and the weight of a tree chain. Output For each tests: A single integer, the maximum number of paths. Sample Input
Sample Output
Hint Stack expansion program: #pragma comment(linker, "/STACK:1024000000,1024000000") Author FZUACM Source | ||||||||||
|