HBC24950[网络流24题]魔术球问题[USACO 2008 Jan S]Telephone Lines题解

2拍不死你 算法基础篇 45 0
全网最全C++题库,助您快速提升编程技能!题库丰富多样,涵盖各个领域,让您在练习中不断成长!
Farmer John wants to set up a telephone line at his farm. Unfortunately, the phone company is uncooperative, so he needs to pay for some of the cables required to connect his farm to the phone system.There are N forlorn telephone poles conveniently numbered 1..N that are scattered around Farmer John's property; no cables connect any them. A total of P pairs of poles can be connected by a cable; the rest are too far apart.As it turns out, the phone company is willing to provide Farmer John with K lengths of cable for free. Beyond that he will have to pay a price equal to the length of the longest remaining cable he requires , or 0 if he does not need any additional cables.Determine the minimum amount that Farmer John must pay.

Farmer John wants to set up a telephone line at his farm. Unfortunately, the phone company is uncooperative, so he needs to pay for some of the cables required to connect his farm to the phone system. There are N (1 ≤ N ≤ 1,000) forlorn telephone poles conveniently numbered 1..N that are scattered around Farmer John's property; no cables connect any them. A total of P (1 ≤ P ≤ 10,000) pairs of poles can be connected by a cable; the rest are too far apart. The i-th cable can connect the two distinct poles Ai and Bi, with length Li (1 ≤ Li ≤ 1,000,000) units if used. The input data set never names any {Ai, Bi} pair more than once. Pole 1 is already connected to the phone system, and pole N is at the farm. Poles 1 and N need to be connected by a path of cables; the rest of the poles might be used or might not be used. As it turns out, the phone company is willing to provide Farmer John with K (0 ≤ K < N) lengths of cable for free. Beyond that he will have to pay a price equal to the length of the longest remaining cable he requires (each pair of poles is connected with a separate cable), or 0 if he does not need any additional cables. Determine the minimum amount that Farmer John must pay.

HBC24950[网络流24题]魔术球问题[USACO 2008 Jan S]Telephone Lines题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
想要在职场中立于不败之地?那就来试试全网最全C++题库,让您在练习中快速提升技能。

标签: HBC24950[网络流24题]魔术球问题[USACO 2008 Jan S]Telephone Lines题解