hdu 3061 最大权闭合子图】的更多相关文章

属于模板题吧... #include <cstdio> #include <cstring> #include <vector> #define min(a,b) ((a)<(b)?(a):(b)) #define oo 0x3f3f3f3f #define N 610 using namespace std; struct Edge { int u, v, f; Edge( int u, int v, int f ):u(u),v(v),f(f){} }; st…
分析:城池之间有依赖关系,汇点与能获得兵力的城池连接,容量为可以获得的兵力,损耗兵力的城池与汇点连接容量为损耗的兵力,有依赖关系的城池间连边,容量为无穷大,跑网络流求出的最小割就是损耗的最小兵力,,, #include<stdio.h> #include<string.h> const int N=510; const int inf=0x3fffffff; int dis[N],gap[N],start,end,ans,head[N],num; struct edge { int…
String problem 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5772 Description This is a simple problem about string. Now a string S contains only '0'-'9'. ?? wants to select a subsequence from this string. And makes this subsequence score maximum.…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5855 Less Time, More profit Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others) 问题描述 The city planners plan to build N plants in the city which has M shops. Each shop needs p…
经典例题,好像说可以转化成maxflow(n,n+m),暂时只可以勉强理解maxflow(n+m,n+m)的做法. 题意:输入n个点,m条边的无向图.点权为负,边权为正,点权为代价,边权为获益,输出最大获益. (最大权闭合子图:图中各点的后继必然也在图中) 构图攻略:将边看做点, 若选某条边e[i](u,v,w),则必须选点u,v.由此构成一个有向图.也符合最大权闭合子图模型. 对原本的边e[i](u,v,w)连3条边(S,n+i,w),(n+i,u,inf),(n+i,v,inf). 对原本的…
样例说明: n(城市数目)   m(工程队数目) 每个工程队上交的税收 val[i] k(k个工程) xi   yi  ci  costi , 工程队ci承包由xi到yi,政府的补贴为costi 注意:如果聘用了工程队c,则所有与工程队c的项目政府都得补贴,并且所有与c相关的工程队也得参与建设(政府补贴).这里的有关系是指: 工程队c,d承包的项目 xc yc , xd yd中yc==xd. 感觉题意好难理解.理解之后就好办了,这不就是裸的最大权闭合子图吗?不懂请看Amber的<论文最小割模型在…
将第i个用户和他需要的基站连边,转化成求二分图的最大权闭合子图. 答案=正权点之和-最小割. # include <cstdio> # include <cstring> # include <cstdlib> # include <iostream> # include <vector> # include <queue> # include <stack> # include <map> # include…
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=4971 Description There's a company with several projects to be done. Finish a project will get you profits. However, there are some technical problems for some specific projects. To solve the proble…
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5855 Description The city planners plan to build N plants in the city which has M shops. Each shop needs products from some plants to make profit of proi units. Building ith plant needs investment o…
/** 题目:hdu3879 Base Station 最大权闭合子图 边权有正有负 链接:http://acm.hdu.edu.cn/showproblem.php?pid=3879 题意:给出n个地方可以建房子,给出每个地方建房子的费用,如果A,B两个地方建了房子,那么可以获得C的利润. 求建一些房子可以获得的最大利润. 思路:最大权闭合子图. n个房子与t相连,容量为费用.如果A,B两个地方建了房子,那么可以获得利润C.可以新增一个点x,s->x,cap=C; x->a,cap=INF;…