https://www.cnblogs.com/137shoebills/p/9100790.html http://poj.org/problem?id=2987 之前写过这道题,码一个dinic的最大流板子. 经典问题,选了一个点就有些点必须选,输出使选出的点的权值和最大的最少点数,并输出该权值和. 建图就是s向权值为正的点连流量为val的边,权值为负的点向t连流量为-val的边,所有的权值和-最大流就是答案. 类似于https://www.cnblogs.com/137shoebills/…
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…
之前的Dinic模板照着刘汝佳写的vector然后十分鬼畜跑得奇慢无比,虽然别人这样写也没慢多少但是自己的就是令人捉急. 改成邻接表之后快了三倍,虽然还是比较慢但是自己比较满意了.虽然一开始ecnt从0开始WA了一发... 之前的码风也十分鬼畜呀缩进只缩1.2格不懂自己怎么想的.. 反正今天就安心划划水. #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #in…
POJ 1273给出M条边,N个点,求源点1到汇点N的最大流量. 本文主要就是附上dinic的模板,供以后参考. #include <iostream> #include <stdio.h> #include <algorithm> #include <queue> #include <string.h> /* POJ 1273 dinic算法模板 边是有向的,而且存在重边,且这里重边不是取MAX,而是累加和 */ using namespace…
http://poj.org/problem?id=2987 https://blog.csdn.net/u014686462/article/details/48533253 给一个闭合图,要求输出其最大权闭合图的权值和需要选的最少点数,最大权闭合图定义和网络流连边方式见博客. #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #include<iostrea…
#include<cstring> #include<cstdio> #define FOR(i,f_start,f_end) for(int i=f_startl;i<=f_end;i++) #define MS(arr,arr_value) memset(arr,arr_value,sizeof(arr)) ; ; int size; int n; const int inf=0x3f3f3f3f; using namespace std; int head[maxn];…
题目链接:http://poj.org/problem?id=2987 You’ve finally got mad at “the world’s most stupid” employees of yours and decided to do some firings. You’re now simply too mad to give response to questions like “Don’t you think it is an even more stupid decisio…
题目链接:http://poj.org/problem?id=2987 Time Limit: 5000MS Memory Limit: 131072K Description You’ve finally got mad at “the world’s most stupid” employees of yours and decided to do some firings. You’re now simply too mad to give response to questions li…
Firing Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 12108   Accepted: 3666 Description You’ve finally got mad at “the world’s most stupid” employees of yours and decided to do some firings. You’re now simply too mad to give response…
题意:给出一个有向图,选择一个点,则要选择它的可以到达的所有节点.选择每个点有各自的利益或损失.求最大化的利益,以及此时选择人数的最小值. 算法:构造源点s汇点t,从s到每个正数点建边,容量为利益.每个负点到t建边,容量为损失的绝对值.其他关系边容量正向无穷,反向0.正数点总和减去最小割即为最大权闭合图答案.因为残余网络不会对0流边处理,所以不会将0流点选入取点集,所以最小割的取法中为被选中的点. 最大权闭合图的求解方法: 先构造网络流N,添加源点s,从s到正权值点做一条边,容量为点的权值. 添…