Pro.ID10191 TitlePollutant Control Title链接http://10.20.2.8/oj/exercise/problem?problem_id=10191 AC2 Submit6 Ratio33.33% 时间&空间限制描述It's your first day in Quality Control at Merry Milk Makers, and already there's been a catastrophe: a shipment of bad milk has been sent out. Unfortunately, you didn't discover this until the milk was already into your delivery system on its way to stores. You know which grocer that milk was destined for, but there may be multiple ways for the milk to get to that store. The delivery system is made up of a several warehouses, with trucks running from warehouse to warehouse moving milk. While the milk will be found quickly, it is important that it does not make it to the grocer, so you must shut down enough trucks to ensure that it is impossible for the milk to get to the grocer in question. Every route costs a certain amount to shut down. Find the minimum amount that must be spent to ensure the milk does not reach its destination, along with a set of trucks to shut down that achieves this goal at that cost. 输入Multiple test cases. For each case : Line 1: Two space separated integers, N and M. N (2 ≤ N ≤ 32) is the number of warehouses that Merry Milk Makers has, and M (0 ≤ M ≤ 1000) is the number of trucks routes run. Warehouse 1 is actually the productional facility, while warehouse N is the grocer to which which the bad milk was destined. Line 2..M+1: Truck routes: three space-separated integers, Si, Ei, and Ci. Si and Ei (1 ≤ Si, Ei ≤ N) correspond to the pickup warehouse and dropoff warehouse for the truck route. Ci (0 ≤ Ci ≤ 2,000,000) is the cost of shutting down the truck route. 输出Description It's your first day in Quality Control at Merry Milk Makers, and already there's been a catastrophe: a shipment of bad milk has been sent out. Unfortunately, you didn't discover this until the milk was already into your delivery system on its way to stores. You know which grocer that milk was destined for, but there may be multiple ways for the milk to get to that store. The delivery system is made up of a several warehouses, with trucks running from warehouse to warehouse moving milk. While the milk will be found quickly, it is important that it does not make it to the grocer, so you must shut down enough trucks to ensure that it is impossible for the milk to get to the grocer in question. Every route costs a certain amount to shut down. Find the minimum amount that must be spent to ensure the milk does not reach its destination, along with a set of trucks to shut down that achieves this goal at that cost. Input Multiple test cases. For each case : Line 1: Two space separated integers, N and M. N (2 ≤ N ≤ 32) is the number of warehouses that Merry Milk Makers has, and M (0 ≤ M ≤ 1000) is the number of trucks routes run. Warehouse 1 is actually the productional facility, while warehouse N is the grocer to which which the bad milk was destined. Line 2..M+1: Truck routes: three space-separated integers, Si, Ei, and Ci. Si and Ei (1 ≤ Si, Ei ≤ N) correspond to the pickup warehouse and dropoff warehouse for the truck route. Ci (0 ≤ Ci ≤ 2,000,000) is the cost of shutting down the truck route. Output For each case, the first line of the output should be two integers, C and T. C is the minimum amount which must be spent in order to ensure the our milk never reaches its destination. T is the minimum number of truck routes that you plan to shut down in order to achive this goal. The next T lines sould contain a sorted list of the indexes of the truck routes that you suggest shutting down. If there are multiple sets of truck routes that achieve the goal at minimum cost, choose one that shuts down the minimum number of routes. If there are still multiple sets, choose the one whose initial routes have the smallest index. Output a blank line after each case. Sample Input 4 5 Sample Output 60 1 Source 样例输入4 5 样例输出60 1 作者 |