In some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numbered with integers from 1 to n. If cities a and b are connected by a road, then in an hour you can go along this road either from city ato city b, or from city b to city a. The road network is such that from any city you can get to any other one by moving along the roads. 继续阅读【最短路】Destroying Roads
There is a tree(the tree is a connected graph which contains points and edges),the points are labeled from 1 to ,which edge has a weight from 0 to 1,for every point ,you should find the number of the points which are closest to it,the clostest points can contain itself.
|Time Limit: 1000MS||Memory Limit: 10000K|
|Total Submissions: 29613||Accepted: 11750|
Farmer John ordered a high speed connection for his farm and is going to share his connectivity with the other farmers. To minimize cost, he wants to lay the minimum amount of optical fiber to connect his farm to all the other farms.
Given a list of how much fiber it takes to connect each pair of farms, you must find the minimum amount of fiber needed to connect them all together. Each farm must connect to some other farm such that a packet can flow from any one farm to any other farm.
The distance between any two farms will not exceed 100,000.