USACO Section 4.2 Drainage Ditches(最大流)

最大流问题。ISAP算法。注意可能会有重边,不过我用的数据结构支持重边。距离d我直接初始化为0,也可以用BFS逆向找一次。
-----------------------------------------------------------------------
-----------------------------------------------------------------------
Drainage Ditches
Hal Burch
Every time it rains on Farmer John's fields, a pond forms over Bessie's favorite clover patch. This means that the clover is covered by water for awhile and takes quite a long time to regrow. Thus, Farmer John has built a set of drainage ditches so that Bessie's clover patch is never covered in water. Instead, the water is drained to a nearby stream. Being an ace engineer, Farmer John has also installed regulators at the beginning of each ditch, so he can control at what rate water flows into that ditch.
Farmer John knows not only how many gallons of water each ditch can transport per minute but also the exact layout of the ditches, which feed out of the pond and into each other and stream in a potentially complex network. Note however, that there can be more than one ditch between two intersections.
Given all this information, determine the maximum rate at which water can be transported out of the pond and into the stream. For any given ditch, water flows in only one direction, but there might be a way that water can flow in a circle.
PROGRAM NAME: ditch
INPUT FORMAT
| Line 1: | Two space-separated integers, N (0 <= N <= 200) and M (2 <= M <= 200). N is the number of ditches that Farmer John has dug. M is the number of intersections points for those ditches. Intersection 1 is the pond. Intersection point M is the stream. |
| Line 2..N+1: | Each of N lines contains three integers, Si, Ei, and Ci. Si and Ei (1 <= Si, Ei <= M) designate the intersections between which this ditch flows. Water will flow through this ditch from Si to Ei. Ci (0 <= Ci <= 10,000,000) is the maximum rate at which water will flow through the ditch. |
SAMPLE INPUT (file ditch.in)
5 4
1 2 40
1 4 20
2 4 20
2 3 30
3 4 10
OUTPUT FORMAT
One line with a single integer, the maximum rate at which water may emptied from the pond.
SAMPLE OUTPUT (file ditch.out)
50
USACO Section 4.2 Drainage Ditches(最大流)的更多相关文章
- USACO Section 4.2: Drainage Ditches
最大流的模板题 /* ID: yingzho1 LANG: C++ TASK: ditch */ #include <iostream> #include <fstream> ...
- POJ 1273 || HDU 1532 Drainage Ditches (最大流模型)
Drainage DitchesHal Burch Time Limit 1000 ms Memory Limit 65536 kb description Every time it rains o ...
- POJ 1273 - Drainage Ditches - [最大流模板题] - [EK算法模板][Dinic算法模板 - 邻接表型]
题目链接:http://poj.org/problem?id=1273 Time Limit: 1000MS Memory Limit: 10000K Description Every time i ...
- Poj 1273 Drainage Ditches(最大流 Edmonds-Karp )
题目链接:poj1273 Drainage Ditches 呜呜,今天自学网络流,看了EK算法,学的晕晕的,留个简单模板题来作纪念... #include<cstdio> #include ...
- poj 1273 Drainage Ditches 最大流入门题
题目链接:http://poj.org/problem?id=1273 Every time it rains on Farmer John's fields, a pond forms over B ...
- TZOJ 4085 Drainage Ditches(最大流)
描述 Every time it rains on Farmer John's fields, a pond forms over Bessie's favorite clover patch. Th ...
- HDU1532 Drainage Ditches —— 最大流(sap算法)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1532 Drainage Ditches Time Limit: 2000/1000 MS (Java/ ...
- poj-1273 Drainage Ditches(最大流基础题)
题目链接: Drainage Ditches Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 67475 Accepted ...
- hdu 1532 Drainage Ditches(最大流)
Drainage Dit ...
随机推荐
- Error occured processing XML 'Cannot find class [springmvc.extention.BeanArgumentResolver]'.
<Description Resource Path Location Type Error occured processing XML 'Cannot find class [springm ...
- C#核编之一个简单的C#程序
构建一个简单的C#应用程序需要注意一下几点: 1.C#要求所有的程序逻辑都包含在一个类型定义中 --->这里的类型指的是(类,接口,结构,枚举,委托中的一个或多个) 2.与其他语言不 ...
- [一个经典的多线程同步问题]解决方案二:Event事件
使用关键段来解决经典的多线程同步互斥问题,由于关键段的“线程所有权”特性所以关键段只能用于线程的互斥而不能用于同步.本篇介绍用事件Event来尝试解决这个线程同步问题. 首先介绍下如何使用事件.事件E ...
- Sql优化(三) 关于oracle的并发
Oracle的并发技术可以将一个大任务分解为多个小任务由多个进程共同完成.合理地使用并发可以充分利用系统资源,提高效率.一. 并发的种类Parallel queryParallel DML(PDML) ...
- 采购件不允许挂BOM
应用 Oracle Bill Of Materiel 层 Level Function 函数名 Funcgtion Name BOM_BOMFDBOM 表单名 Form Name BOMFDBOM ...
- onActivityResult不起作用?可能是和你的launchMode有关!
昨天在自己的项目中用到了onActivityResult()方法获得activity的返回值.我从Activity01通过 startActivityForResult启动了Activity02和Ac ...
- Top free and open source log management software
As mentioned in the previous post, in my quest to find an alternative to Kiwi Syslog, I looked at a ...
- js获取宽度设置thickbox百分比
thickbox的宽高不好设为百分比,这样遇到不同的尺寸的电脑就会出现问题. 怎么做呢? 通过js来处理. <script type="text/javascript"> ...
- Unix/Linux环境C编程入门教程(16) LinuxMint CCPP开发环境搭建
1. Linux Mint由Linux Mint Team团队于2006年开始发行,是一份基于 这个时候linuxmint安装完成,C/C++开发环境也配置完成,希望大家认真实践!
- uva 10129 poj 1386 hdu 1116 zoj 2016 play on words
//本来是想练一下欧拉回路的,结果紫书上那题是大水题!!!!! 题意:给出n个单词,是否可以把单词排列成每个单词的第一个字母和上一个单词的最后一个字母相同 解:欧拉通路存在=底图联通+初度!=入度的点 ...