您的位置:首页 > 其它

Road System HUST 1631 最小生成树

2015-08-08 11:04 330 查看
B - Road System
Time Limit:1000MS     Memory Limit:131072KB     64bit IO Format:%lld
& %llu
Submit Status Practice HUST
1631

Description

There are M cities in a map.Alice wants to find some roads to make all of the cities can be reached if she starts her journey from other cities.

With kind Bob's investigation and assessment, she got the resulting statistics about construction cost of some roads.However, her money is limited, 

so she asks you to make a plan which costs the least to meet her goal.Can you help her? 

Input

The first line contains an integer t meaning that there are T test cases(T <= 20).  

For each test case: 

The first line contains two integers, N and M, indicating the number of roads and cities. (0<=N<=100, 1<=M<=100).Then for each of the following N lines, there are three non-negative A, B, W, meaning that if a road is built between a and b, it costs w.(0<=w<=1000). 

Output

For each test case, you need output a line containing an integer indicating the least cost of the plan, or if you can't get the answer with the information you're given, output "I'm not sure." instead. 

Sample Input

1
3 3
1 2 1
1 3 2
2 3 4


Sample Output

3


题目连接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82557#problem/B

题目大意:

解题思路:

算法知识:

学习指导:

My参考代码:
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: