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

poj2455 k条路最小化最长边的更多相关文章

  1. 分层图 (可以选择K条路的权为0,求最短路)

    分层图可以处理从图中选取k条边使其边权变为0,求最短路 Description 在你的强力援助下,PCY 成功完成了之前的所有任务,他觉得,现在正是出去浪的大好时光.于是,他来到高速公路上,找到一辆摩 ...

  2. Crowd Control(输出不在最大值最小化的最短路上的边)

    题意: 就是求完最大值最小化  然后输出在这条最大值最小化的最短路上的点的不在最短路上的边,emm.... 解析: 很明显,先套spfa最大值最小化模板,emm... 在更新d的时候 用一个pre去记 ...

  3. poj 3613 经过k条边最短路 floyd+矩阵快速幂

    http://poj.org/problem?id=3613 s->t上经过k条边的最短路 先把1000范围的点离散化到200中,然后使用最短路可以使用floyd,由于求的是经过k条路的最短路, ...

  4. poj_3662 最小化第k大的值

    题目大意 有N个节点以及连接的P个无向边,现在要通过这P条边从1号节点连接到N号节点.若无法连接成功,则返回-1:若能够连接成功,那么其中用到了L条边,这L条边中有K条边可以免费,L-K条边不能免费, ...

  5. POJ-3662 Telephone Lines---二分+最短路+最小化第k+1大

    题目链接: https://cn.vjudge.net/problem/POJ-3662 题目大意: 求一条路径从1到n使第k+1大的边最小. 解题思路: 二分答案mid,当原边权小于等于mid新边权 ...

  6. POJ 2253 Frogger【最短路变形/最小生成树的最大权/最小瓶颈树/A到B多条路径中的最小的最长边】

    Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sit ...

  7. Java之路(六) 局部变量作用域最小化

    将局部变量的作用域最小化,可以增强代码的可读性和可维护性,并降低出错的可能性. 将局部变量的作用域最小化的方法有: 方法1:在第一次使用某个局部变量的地方进行声明. a.Java可以在任何可以出现语句 ...

  8. POJ 3662 Telephone Lines (二分+Dijkstra: 最小化第k大的值)

    题意 Farmer John想从电话公司修一些电缆连接到他农场.已知N个电线杆编号为1,2,⋯N,其中1号已经连接电话公司,N号为农场,有P对电线杆可连接. 现给出P对电线杆距离Ai,Bi,Li表示A ...

  9. How Javascript works (Javascript工作原理) (十四) 解析,语法抽象树及最小化解析时间的 5 条小技巧

    个人总结:读完这篇文章需要15分钟,文章介绍了抽象语法树与js引擎解析这些语法树的过程,提到了懒解析——即转换为AST的过程中不直接进入函数体解析,当这个函数体需要执行的时候才进行相应转换.(因为有的 ...

随机推荐

  1. 【Linux常见命令】find命令

    find - search for files in a directory hierarchy find命令用来在指定目录下查找文件. 任何位于参数之前的字符串都将被视为欲查找的目录名. 如果使用该 ...

  2. 以内存级速度实现存储?XPoint正是我们的计划

    随着计算能力虚拟化技术的普及,存储机制在速度上远逊于内存这一劣势开始变得愈发凸显. 这一巨大的访问速度鸿沟一直是各项存储技术想要解决的核心难题:纸带.磁带.磁盘驱动器乃至闪存记忆体等等,而如今最新一代 ...

  3. 安装opencv3.3.0方法

    #系统环境:CentOS6.5 x64 #首先安装jdk7u80 mkdir  /java tar -zxvf  jdk-7u80-linux-x64.gz  -C  /java/ vim  /etc ...

  4. Nginx比SRS做得好的地方

    在nginx.org文档中,摘录了一篇nginx介绍的文章,Chapter “nginx” in “The Architecture of Open Source Applications”,这篇文章 ...

  5. 杭电的题,输出格式卡的很严。HDU 1716 排列2

    题很简单,一开始写代码,是用整数的格式写的,怎么跑都不对,就以为算法错了,去看大佬们的算法STL全排列:next_permutation(); 又双叒叕写了好几遍,PE了将近次,直到跑了大佬代码发现, ...

  6. CF--思维练习--CodeForces - 219C Color Stripe (思维)

    ACM思维题训练集合 A colored stripe is represented by a horizontal row of n square cells, each cell is paine ...

  7. 2020最新nginx+gunicorn+supervisor部署基于flask开发的项目的生产环境的详细攻略

    本攻略基于ubuntu1804的版本,服务器用的华为云的服务器,python3(python2已经在2020彻底停止维护了,所以转到python3是必须的)欢迎加我的QQ6398903,或QQ群讨论相 ...

  8. python(类多态)

    一.多态 (以封装和继承为前提)不同的子类调用相同的方法,产生不同的结果 class Dog(): def __init__(self,name): self.name = name def game ...

  9. HMM-前向后向算法

    基本要素 状态 \(N\)个 状态序列 \(S = s_1,s_2,...\) 观测序列 \(O=O_1,O_2,...\) \(\lambda(A,B,\pi)\) 状态转移概率 \(A = \{a ...

  10. 一篇博客带你轻松应对Springboot面试

    1. SpringBoot简介 SpringBoot是简化Spring应用开发的一个框架.他整合了Spring的技术栈,提供各种标准化的默认配置.使得我们可以快速开发Spring项目,免掉xml配置的 ...