zoukankan      html  css  js  c++  java
  • poj2455 k条路最小化最长边

    Secret Milking Machine
    Time Limit: 1000MS   Memory Limit: 65536K
    Total Submissions: 12414   Accepted: 3625

    Description

    Farmer John is constructing a new milking machine and wishes to keep it secret as long as possible. He has hidden in it deep within his farm and needs to be able to get to the machine without being detected. He must make a total of T (1 <= T <= 200) trips to the machine during its construction. He has a secret tunnel that he uses only for the return trips.

    The farm comprises N (2 <= N <= 200) landmarks (numbered 1..N) connected by P (1 <= P <= 40,000) bidirectional trails (numbered 1..P) and with a positive length that does not exceed 1,000,000. Multiple trails might join a pair of landmarks.

    To minimize his chances of detection, FJ knows he cannot use any trail on the farm more than once and that he should try to use the shortest trails.

    Help FJ get from the barn (landmark 1) to the secret milking machine (landmark N) a total of T times. Find the minimum possible length of the longest single trail that he will have to use, subject to the constraint that he use no trail more than once. (Note well: The goal is to minimize the length of the longest trail, not the sum of the trail lengths.)

    It is guaranteed that FJ can make all T trips without reusing a trail.

    Input

    * Line 1: Three space-separated integers: N, P, and T

    * Lines 2..P+1: Line i+1 contains three space-separated integers, A_i, B_i, and L_i, indicating that a trail connects landmark A_i to landmark B_i with length L_i.

    Output

    * Line 1: A single integer that is the minimum possible length of the longest segment of Farmer John's route.

    Sample Input

    7 9 2
    1 2 2
    2 3 5
    3 7 5
    1 4 1
    4 3 1
    4 5 7
    5 7 1
    1 6 3
    6 7 3

    Sample Output

    5

    二分最长边,然后按边的权值排序加边,然后加边权值是1,就可以保证一条路只能用一次了。然后判断最大流,如果大于等于路的数量,就说明true,然后二分就可以了

    注意无向图加反向边的时候权值不是0

  • 相关阅读:
    flex 布局 shrink 属性
    flex 布局 flex-grow 属性
    flex 布局 flex-basis 属性
    flex 布局 justify-content 对齐的图解
    CSS定位要点笔记
    CSS浮动要点笔记
    CSS选择器要点笔记
    eslint no-unused-vars 解决办法
    NodeJs使用Promise解决多层异步调用的简单学习
    windows10 搭建 NTP 时间服务器
  • 原文地址:https://www.cnblogs.com/mfys/p/7445634.html
Copyright © 2011-2022 走看看