弱爆了,典型的行列建模方式,居然想不到,题做少了,总结少了...... 二分答案mid s----------------------->i行----------------------->j列----------------------------->t [si-mid,si+mid]                  [L,R]                 [s[j]-mid,s[j]+mid] 即对每一行建一个点,每一列建一个点,用边来表示某一行某一列上的东西. 这种建模方式一…
#include <cstdio> #include <cstring> #define min(a,b) ((a)<(b)?(a):(b)) #define oo 0x3f3f3f3f #define N 210 #define M 100010 struct Dinic { int n, src, dst; int head[N], dest[M], flow[M], eid[M], next[M], etot; int cur[N], dep[N], qu[N], bg…
Description We are supposed to make a budget proposal for this multi-site competition. The budget proposal is a matrix where the rows represent different kinds of expenses and the columns represent different sites. We had a meeting about this, some t…
"Oh, There is a bipartite graph.""Make it Fantastic."X wants to check whether a bipartite graph is a fantastic graph. He has two fantastic numbers, and he wants to let all the degrees to between the two boundaries. You can pick up seve…
Problem Description Tom is a commander, his task is destroying his enemy’s transportation system. Let’s represent his enemy’s transportation system as a simple directed graph G with n nodes and m edges. Each node is a city and each directed edge is a…
题意:无源无汇有上下界的可行流 模型 思路:首先将所有边的容量设为上界减去下界,然后对一个点i,设i的所有入边的下界和为to[i],所有出边的下界和为from[i],令它们的差为dif[i]=to[i]-from[i],根据流量平衡原理,让出边和入边的下界相抵消,如果dif[i]>0,说明入边把出边的下界抵消了,还剩下dif[i]的流量必须要流过来(否则不满足入边的下界条件),这时从源点向i连一条容量为dif[i]的边来表示即可,如果dif[i]<0,同理应该从i向汇点连一条容量为-dif[i…
先连一条从汇点到源点的容量为INF的边,将其转化成无源汇点有上下界的可行流,判断是否可行 若可行的话删掉超级源点和超级汇点,再跑一遍最大流即可 #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <queue> #include <cstdlib> using name…
对于无源汇问题,方法有两种. 1 从边的角度来处理. 新建超级源汇, 对于每一条有下界的边,x->y, 建立有向边 超级源->y ,容量为x->y下界,建立有向边 x-> 超级汇,容量为x->y下界.建立有向边 x->y,容量为x->y的上界减下界. 2 从点的角度来处理. 新建超级源汇,对于每个点流进的下界和为 in, 流出此点的下界和为out.如果in > out. 建立有向边 超级源->i,容量为in-out.反之,建立有向边 i->超级汇…
前几天正看着网络流,也正研究着一个有上下界的网络流的问题,查看了很多博客,觉得下面这篇概括的还是相当精确的: http://blog.csdn.net/leolin_/article/details/7208246 里面包含了其中一些解释.看了这道题的题解之后就会发现确实好像就是一个无源的有上下界的可行流. #pragma warning(disable:4996) #include <iostream> #include <cstring> #include <string…
https://nanti.jisuanke.com/t/31447 题意 一个二分图,左边N个点,右边M个点,中间K条边,问你是否可以删掉边使得所有点的度数在[L,R]之间 分析 最大流不太会.. 贪心做法: 考虑两个集合A和B,A为L<=d[i]<=R,B为d[i]>R 枚举每个边 1.如果u和v都在B集合,直接删掉2.如果u和v都在A集合,无所谓3.如果u在B,v在A,并且v可删边即d[v]>L4.如果u在A,v在B,并且u可删边即d[u]>L 最后枚举N+M个点判断是…