POJ 1149 PIGS 建图,最大流】的更多相关文章

题意: 你m个猪圈以及每个猪圈里原来有多少头猪,先后给你n个人,每个人能打开某一些猪圈并且他们最多想买Ki头猪,在每一个人买完后能将打开的猪圈中的猪顺意分配在这次打开猪圈里,在下一个人来之前 已打开的猪圈会被锁上.问最多能卖几头猪 分析: 这个题明着想呢,肯定是要建N排点的,表示相同的猪圈的点连inf边,跑最大流的. 建那么多点肯定是会炸的. 在网络流中呢,如果我们做题的初步思路是最大流,那么肯定要将题目中问的直接问题抽象成水流,比如这道题,问最多的卖猪数,我们当然就要把猪的数量作为“流”,这是…
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: 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…
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…
题意以及分析:http://ycool.com/post/zhhrrm6#rule3 主要是建图,简化图,然后在套最大流的模板. #include <iostream> #include<string.h> #include<cstdio> using namespace std; struct Node { int v,cap,flow,next; Node(){} Node(int _v,int _cap,int _flow,int _next) { v=_v; c…
建图:s向所有猪圈的第一个顾客连流量为这个猪圈里住的数量,然后对于之后每个来这个猪圈的顾客,由他前一个顾客向他连边权为无穷的边,然后每个顾客向t连流量为这个顾客购买上限的边.然后跑最大流 #include<iostream> #include<cstdio> #include<vector> #include<cstring> #include<queue> using namespace std; const int M=1005,N=105,…
<题目链接> 题目大意:有一个养猪场,厂长没有钥匙,这个养猪场一共M个猪圈,N个顾客,每个顾客有一些猪圈的钥匙,每个顾客需要一些猪,问你厂长最多能卖多少猪?这里有个条件是,厂长可以在一个顾客买完后,调整没有锁门的猪圈中猪数量,比如,把几个猪圈中的猪全部转到一个猪圈内(这个条件会影响到后期建图),然后再关门,等下一个顾客. 解题分析: 首先根据题意,将这个问题抽象成一个朴素的模型, 因为这样建图,图中最多可能有$2+N+M+N*M (≍1e5)$个节点.在这样的图上跑网络流速度会很慢,我们可以通…
PIGS Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 20579   Accepted: 9387 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…
PIGS 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…