1631 - Road System
Time Limit : 1 Second
Memory Limit : 128 MB
Submission: 393
Solved: 105
- 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
- hint
- source
- The 8th(2013) ACM Programming Contest of HUST