Nature of the network flow model
1> capacity limit : $ f (x, y) $ <= $ c (x, y) $
2> skew symmetric : $ f (x, y) $ = - $ f (y, x) $
3> flow conservation : in addition to S or T, each point is equal to flow out of the inflow rate
The maximum flow
It refers to the maximum flow problem given S and T, to obtain the maximum flow rate S to T
This figure is the maximum flow 2, but if we put this figure to skyh, then he will go S-> 2-> 3-> T, a flow rate of 1
He wrote more than a
How can we go back on the use of some operation to ensure maximum flow it?
By augmenting path
We use the skyh FIG skew-symmetric nature of reverse flow out while adding a look
Amazingly, we found a path, it continues to flow past
Finally reaching the optimal solution with the same effect
General augmenting path algorithm will be used Ek or dinic
However, the maximum flow generally used dinic
Is the same for both first with a layered diagram, except that multiple dinic is augmented
Code and hold it
T1 strange game
Title Description
Input Format
Output Format
相邻格子不难想到二分图染色,设白色的个数为$sum1$,总和为$num1$,黑色为$sum2$,$num2$,最终状态为x
那么便有$sum1*x-num1$=$sum2*x-num2$
1>$sum1$=$sum2$
直接二分并且用网络流$check$
注意需要满足$num1$=$num2$
2>$sum1$!=$sum2$($abs$($sum1-sum2$)=1)
$x$=$abs$($num1$-$num2$),$check$一下是否合法便是答案
网络流建图:
($S$,$white$,$x-last$),($black$,$T$,$x-last$),($white$,$black$,$INF$)
T2士兵占领
题目描述
输入格式
输出格式
考虑把至少放置转化成至多不放置,之后按行列转化成二分图,可以放置的地方化为边
于是它便成了一道最大流板子题
T3紧急疏散
题目描述
输入格式
输出格式
这道题用到了一个常用的套路:按时间拆点
显然满足单调性,但是直接二分会T,
我们发现check复杂度过高,反而二分的区间很小
所以考虑直接枚举时间,在上一个时间的残余网络上跑最大流