PIGS POJ - 1149(水最大流)】的更多相关文章

题意: 有M个猪圈,每个猪圈里初始时有若干头猪.一开始所有猪圈都是关闭的.依次来了N个顾客,每个顾客分别会打开指定的几个猪圈,从中买若干头猪.每个顾客分别都有他能够买的数量的上限.每个顾客走后,他打开的那些猪圈中的猪,都可以被任意地调换到其它开着的猪圈里,然后所有猪圈重新关上.问总共最多能卖出多少头猪.(1 <= N <= 100, 1 <= M <= 1000) 解析: 因为是依次 所以对于当前第i个顾客 所对应的猪圈 向前 i - 1 个顾客种有对应这个猪圈的顾客的其它猪圈 就…
A - PIGS POJ - 1149 这个题目我开始感觉很难,然后去看了一份题解,写的很好 https://wenku.baidu.com/view/0ad00abec77da26925c5b01c.html 这个总结了很多东西,可以去看看学习学习. 从这个题目可以学到的是先建出一个正确但是可能效率很低的模型出来,然后再去减少节点数量, 最后就可以解决这个题目了,这个说起来还挺简单的,但是并不是那么好做. #include <cstdio> #include <cstring>…
POJ - 1149 思路: 最大流: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define maxn 105 #define maxm 1005 #define maxque 200005 #define INF 0x7fffffff int n,m,val[maxm],last[maxm]…
题意: 第一行输入m和n,m是猪圈的数量,n是顾客的数量,下面n行 第 i+1行表示第i个顾客 , 输入第一个数字表示有几把猪圈的钥匙,后面输入对应的猪圈,最后一个数字输入顾客想买几头猪. 建图: 设一个源点 s 和一个汇点 t,s 连接猪圈被第一个打开的顾客,权值为猪圈的猪数量,t 与顾客相连,权值为顾客想要的猪的数量,因为题上说迈克会根据下一个顾客的需求来将猪转移到合适的猪圈,所以顾客与同一猪圈排队的后面紧邻的顾客相连,权值为正无穷. 想一下感觉挺对的,s点有无数头猪,但是边的权值为猪圈的数…
PIGS Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 20738   Accepted: 9481 Description Mirko works on a pig farm that consists of M locked pig-houses and Mirko can't unlock any pighouse because he doesn't have the keys. Customers come t…
题目大意:是有M个猪圈,N个顾客,顾客要买猪,神奇的是顾客有一些猪圈的钥匙而主人MIRKO却没有钥匙,多么神奇?顾客可以在打开的猪圈购买任意数量的猪,只要猪圈里有足够数量的猪.而且当顾客打开猪圈后mirko就可以在打开的猪圈之间任意调整猪的数量,(顾客走了之后猪圈要关闭).问mirko怎样做能使顾客买到最多的猪 思路如下:(也是查的,具体原理和原因明天更新) 1.取超级源点和超级汇点: 2.当猪圈被第一次打开时,在源点与当前顾客之间连接一条边,容量为该猪圈的猪的头数: 3.当某个猪圈 不是被第一…
PIGS Time Limit: 1000ms Memory Limit: 10000KB This problem will be judged on PKU. 64-bit integer(整数) IO format: %lld      Java class name: Main   Mirko works on a pig farm that consists of M locked pig-houses and Mirko can't unlock any pighouse becau…
Time Limit: 1000MS Memory Limit: 10000K Description Mirko works on a pig farm that consists of M locked pig-houses and Mirko can't unlock any pighouse because he doesn't have the keys. Customers come to the farm one after another. Each of them has ke…
Description Mirko works on a pig farm that consists of M locked pig-houses and Mirko can't unlock any pighouse because he doesn't have the keys. Customers come to the farm one after another. Each of them has keys to some pig-houses and wants to buy a…
PIGS Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 18727   Accepted: 8508 Description Mirko works on a pig farm that consists of M locked pig-houses and Mirko can't unlock any pighouse because he doesn't have the keys. Customers come t…