|
||||||||||
ArrestTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2203 Accepted Submission(s): 887 Problem Description There are (N+1) cities on TAT island. City 0 is where police headquarter located. The economy of other cities numbered from 1 to N ruined these years because they are all controlled by mafia. The police plan to catch all the mafia gangs in these N cities all over the year, and they want to succeed in a single mission. They figure out that every city except city 0 lives a mafia gang, and these gangs have a simple urgent message network: if the gang in city i (i>1) is captured, it will send an urgent message to the gang in city i-1 and the gang in city i -1 will get the message immediately. The mission must be carried out very carefully. Once a gang received an urgent message, the mission will be claimed failed. You are given the map of TAT island which is an undirected graph. The node on the graph represents a city, and the weighted edge represents a road between two cities(the weight means the length). Police headquarter has sent k squads to arrest all the mafia gangs in the rest N cities. When a squad passes a city, it can choose to arrest the gang in the city or to do nothing. These squads should return to city 0 after the arrest mission. You should ensure the mission to be successful, and then minimize the total length of these squads traveled. Input There are multiple test cases. Each test case begins with a line with three integers N, M and k, here M is the number of roads among N+1 cities. Then, there are M lines. Each of these lines contains three integers X, Y, Len, which represents a Len kilometer road between city X and city Y. Those cities including city 0 are connected. The input is ended by ¡°0 0 0¡±. Restrictions: 1 ¡Ü N ¡Ü 100, 1 ¡Ü M ¡Ü 4000, 1 ¡Ü k ¡Ü 25, 0 ¡Ü Len ¡Ü 1000 Output For each test case,output a single line with a single integer that represents the minimum total length of these squads traveled. Sample Input
Sample Output
Source | ||||||||||
|