POJ 1273 Drainage Ditches POJ 1274 The Perfect Stall 最大流简单题

来源:互联网 发布:为什么需要编程语言 编辑:程序博客网 时间:2024/06/08 16:31

http://acm.pku.edu.cn/JudgeOnline/problem?id=1273

POJ 1273 Drainage Ditches
Time Limit:1000MS  Memory Limit:10000K
Total Submit:3488 Accepted:1188

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 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.
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

Source
USACO 93

 

http://acm.pku.edu.cn/JudgeOnline/problem?id=1274

POJ 1274 The Perfect Stall
Time Limit:1000MS  Memory Limit:10000K
Total Submit:1464 Accepted:666

Description
Farmer John completed his new barn just last week, complete with all the latest milking technology. Unfortunately, due to engineering problems, all the

stalls in the new barn are different. For the first week, Farmer John randomly assigned cows to stalls, but it quickly became clear that any given cow was

only willing to produce milk in certain stalls. For the last week, Farmer John has been collecting data on which cows are willing to produce milk in which

stalls. A stall may be only assigned to one cow, and, of course, a cow may be only assigned to one stall.
Given the preferences of the cows, compute the maximum number of milk-producing assignments of cows to stalls that is possible.

Input
The input includes several cases. For each case, the first line contains two integers, N (0 <= N <= 200) and M (0 <= M <= 200). N is the number of cows that

Farmer John has and M is the number of stalls in the new barn. Each of the following N lines corresponds to a single cow. The first integer (Si) on the line

is the number of stalls that the cow is willing to produce milk in (0 <= Si <= M). The subsequent Si integers on that line are the stalls in which that cow

is willing to produce milk. The stall numbers will be integers in the range (1..M), and no stall will be listed twice for a given cow.

Output
For each case, output a single line with a single integer, the maximum number of milk-producing stall assignments that can be made.

Sample Input

5 5
2 2 5
3 2 3 4
2 1 5
3 1 2 5
1 2

Sample Output

4

Source
USACO 40

 


Description:
两道最大流简单题 考察基本建图和基本的Edmonds-Karp算法
建图(有向简单图)很简单 应用Edmonds-Karp就能AC 

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 六个月的宝宝脖子有点歪怎么办 情感交叉擦腿综合症心里治疗怎么办 坐月子受风了胳膊腿疼怎么办 劲椎手术两个月双腿疼痛麻这怎么办 手机里存的照片删除了怎么办 买了好几双鞋子都不防滑怎么办 电脑平车车加绒过厚不起线怎么办 碰见那种看不起人的店员应该怎么办 在食品厂上班載卫生帽头发痒怎么办 工司没给员工上保险离职后怎么办 货物被香港律政司扣了怎么办 室友考研要跟我考一样的学校怎么办 药流第一天才吃了一粒米非司怎么办 药流半月同房第二天大出血怎么办 口臭想让它变得不臭怎么办 来单位干了几天不满意想离职怎么办 药流吃药期间吃什么吐什么怎么办 养狗家里味道大怎么办养花有用吗 第一天上班站的脚疼怎么办 入职没有人事所需要的证书怎么办 入职第一天后不想去了怎么办 警察在执法过程中殴打群众怎么办 肾结石打了3天针痛得厉害怎么办 征兵体检过了到部队退兵怎么办 圆通快递要求退回结果被签收怎么办 新生儿蛋蛋淹了破皮了怎么办 要是和同学玩的时候打到睾丸怎么办 睾丸撞了一下里面碎了怎么办 睾丸被蚊子咬了挠坏流水疼怎么办 沐浴乳大量的灌注到尿道里怎么办 当电脑显示有文件损害时怎么办? 电脑上的压缩包手机上打不开怎么办 第五人格多酷账号退出了怎么办 更新显卡驱动时屏幕关闭了怎么办 不知道杯孕做了两次C丁怎么办 小说签约后更不到要求的字数怎么办 电脑中了感染病毒杀不干净怎么办 电脑下载的软件有病毒了怎么办 电脑强制关机后开不了机怎么办 受刺激后出现精神异常该怎么办 当屏幕出现暂时无法移动时怎么办