Problem H. Connect the Cities
时间限制 1000 ms
内存限制 32 MB
In 2100, since the sea level rise, most of the cities disappear. Though some survived cities are still connected with others, but most of them become disconnected. The government wants to build some roads to connect all of these cities again, but they don’t want to take too much money.
输入数据
输出数据
For each case, output the least money you need to take, if it’s impossible, just output -1.
样例输入
复制
1
6 4 3
1 4 2
2 6 1
2 3 5
3 4 33
2 1 2
2 1 3
3 4 5 6
样例输出
$ Mathjax font initiator $