最大流-hdoj-1532

hdoj-1532-Drainage Ditches

Problem Description

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 a while and  takes quite along 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. 

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. 

Input

The input includes several cases. For each case, the first line contains 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. Each of the following 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.

Output

For each case, output a single integer, the maximum rate at which water may emptied from the pond. 

Sample Input

5 4

1 2 40

1 4 20

2 4 20

2 3 30

3 4 10

Sample Output

50

大意:为防止三叶草被淹,挖沟散水。求最大流。以示例输入进行说明。5为边数,4为顶点数。顶点编号从1开始。1为源点,4为汇点。接下来的5行,Si Ei Ci:水从Si流向Ei,最大流量为Ci。只能单向流哦。

 

时间: 2024-08-17 18:42:42

最大流-hdoj-1532的相关文章

Delphi压缩流和解压流的应用

软件开发者不免都要遇到压缩数据的问题!经常使用Delphi的朋友都知道,它为我们提供了两个流类(TCompressionStream和TDecompressionStream)来完成数据的压缩和解压缩,但美中不足的是,该流在Delphi 的帮助中没有详细的说明,使得它们在使用起来有一定得困难.其实在Delphi系统中提供了这两个类的源代码和库.保存在Delphi 光盘的InfoExtraslib Src和InfoExtraslibObj目录中(其中OBJ目录中保存的是库,Src目录中保存的是源代

【转】Java I/O流概念分析整理

转载地址:http://blog.csdn.net/yuebinghaoyuan/article/details/7388059  Java中的流,可以从不同的角度进行分类. 按照数据流的方向不同可以分为:输入流和输出流. 按照处理数据单位不同可以分为:字节流和字符流. 按照实现功能不同可以分为:节点流和处理流. 输出流: 输入流: 因此输入和输出都是从程序的角度来说的. 字节流:一次读入或读出是8位二进制. 字符流:一次读入或读出是16位二进制. 字节流和字符流的原理是相同的,只不过处理的单位

PostgreSQL 流式统计 - insert on conflict 实现 流式 UV(distinct), min, max, avg, sum, count ...

标签 PostgreSQL , 流式统计 , insert on conflict , count , avg , min , max , sum 背景 流式统计count, avg, min, max, sum等是一个比较有意思的场景,可用于实时大屏,实时绘制统计图表. 比如菜鸟.淘宝.阿里游戏.以及其他业务系统的FEED日志,按各个维度实时统计输出结果.(实时FEED统计,实时各维度在线人数等) PostgreSQL insert on conflict语法以及rule, trigger的功

图片加水印-C#图片以流的形式加水印

问题描述 C#图片以流的形式加水印 用流读取的图片,我在上面加了文字水印. 但是我要怎么控制水印的位置,比如说我要加到右下角.应该怎么算坐标?(同一个坐标 .jpg格式跟tif格式位置不一样.)下面是我的代码: /// /// 图片加水印 /// /// 图片路径 /// 字体 /// 字体大小 /// 水印位置 /// 水印文字 /// 存储图片的文件夹 public void AddWaterText(string oldPath,string font,int fontSize,strin

android上 用ffmpeg解码rtp组播流

问题描述 android上 用ffmpeg解码rtp组播流 android上 用ffmpeg解码rtp组播流,avformat_find_stream_info这一步总是失败,错误信息是 Connection timed out,同样的代码linux下测试是没问题的,移植到android后就不行,这是为什么呢? 解决方案 Connection timed out 连接超时.看看网络处理是否正确!! 解决方案二: 权限,看看权限,打印一些日志.安卓上的各位权限都看看! 解决方案三: 我也遇到这个问

求大神解答一下-java中对象流objectstream问题

问题描述 java中对象流objectstream问题 输出的为什么不是cyh男20 ym女20求大神解答!!!!!!!!!! 解决方案 你的代码和我这个一样吗?麻烦把你的代码粘全了,我看看 解决方案二: 这个是照片......... 解决方案三: 我和你写的差不多,不知道你为啥会这样,我给你粘出我的代码package lianxi; import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOE

jsp-我同时用了字符流和response,产生了这个错误,但我需要跳转页面,怎么解决???

问题描述 我同时用了字符流和response,产生了这个错误,但我需要跳转页面,怎么解决??? 2015-1-28 17:42:09 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet action threw exception java.lang.IllegalStateException at org.apache.catalina.connector.Response

如何打造千万级Feed流系统?阿里数据库技术解读

2017年的双十一又一次刷新了记录,交易创建峰值32.5万笔/秒.支付峰值25.6万笔/秒.而这样的交易和支付等记录,都会形成实时订单Feed数据流,汇入数据运营平台的主动服务系统中去.数据运营平台的主动服务,根据这些合并后的数据,实时的进行分析,进行实时的舆情展示,实时的找出需要主动服务的对象等,实现一个智能化的服务运营平台. 通过RDS PostgreSQL和HybridDB for PGSQL实时分析方案: 承受住了每秒几十万笔的写入吞吐并做数据清洗,是交易的数倍 实现分钟级延迟的实时分析

快速可扩展的Ajax流代理——提供持续下载跨域数据

简介 由于浏览器禁止跨域的XMLHTTP调用,所有的Ajax网站都必须有一个服务端代理来从外部域比如Flickr或者Digg来抓去内容.对客户端Javascript代码来说,一个XMLHttp的调用将请求传递给宿主在相同域里的服务端代理,然后由代理来从外部服务器上下载内容,并回传给客户端.通常,所有从外部服务器获取内容的Ajax站点都采用这种代理方案,除了一些罕见的使用JSONP的人.当网站上的许多组件正在从外部域下载内容时,这样的代理将会被大量地调用.所以,当代理开始被百万次地调用时,它将变成

Java IO--字节-字符流转换OutputStreamWriter/InputStreamReader

OutputStreamWriter和InputStreamReader 一般在操作输入输出内容的就需要使用字节或字符流,但是有些时候需要将字符流变为字节流的形式,或者将字节流变为字符流的形式,所以,就需要另外一组转换流的操作类. import java.io.* ; public class OutputStreamWriterDemo01{ public static void main(String args[]) throws Exception { // 所有异常抛出 File f =