Thematic network flow summary

 so hard

 

I maximum flow

In fact, the maximum flow bare or very little, usually requires a combination of a number of other knowledge

Usually it needs to be split points

$ "HNOI2007" emergency evacuation evacuate $

Can we find that the withdrawal is clearly monotone

Half the evacuation time, the key is how $ check $

It found that the most troublesome is the same door each time only one person

Consider split point, the split door into a door at each time point i is connected to the sink side flow like a

Only you need to determine whether the flow is equal to the maximum number of people like

Of course, you can also directly enumeration time and then dynamically built side

 

II minimum cut

The most frequent point of knowledge

In general, in the case of election or do not choose sides have linked some of the need to use the minimum cut

Also often used corpus = maximum - minimum cut

Built Figure way:

1, Original

$ Elevation $

After carefully reading the meaning of the questions can be found, the height of the point of only $ 0 / $ 1

We found that the answer is to continue to observe a minimum cut of artwork

However, direct run and $ TLE $

Introducing: Dual FIG.

The plan view of each of the closed region as a point, if the original deposit side has two closed region in the new image even an edge, is worth noting that between two points, the entire region is a plan view of the outside of the "closed regions "(i.e., points S and T). So get a new map, what we call dual graph

For a plan view, the shortest is the maximum flow for dual graph of the original

For this problem, it has already given the very plan

We then each edge turning pair FIG get a picture of 90 °

2, pulled meaning of the questions, observe nature

 Most of this area is the biggest problem right closed subgraph

 Closed subgraph maximum weight: with n items, each item has a Val (integer), and each item has a set dependency, i.e. select items x, x should be selected depends items, and ask the maximum weight value

 In most cases this is a long build chart

 

  Changes to

  

 

$happiness$

Maximum dependent relationship, the maximum weight looks like a closed subgraph

But this is not a simple question in the election or do not choose which point, choosing instead to a point of ownership

We put aside the maximum weight considered separately minimal cut

The $ S, T $ A $ are considered (arts) $ and $ B (Science) $

1, $ S $ i is connected to each of the points A flow rate of $ [i] $ sides, each point T to the side connected to the flow rate B [i] is

2, to a new point $ a [i] [j] $ represents $ i, j $ while the contribution of selected articles

3, 连接 $ (a [i] [j], i, inf), (a [i] [j], j, inf), (S, a [i] [j], A [i] [j] ) $

4,新建点b[i][j]表示i,j同时选理的贡献

5,连接$(i,b[i][j],inf),(j,b[i][j],inf),(b[i][j],T,B[i][j])$

跑最大流即可

答案为全集-最大流

 

$老C的方块$

这题主要考察最小割中分层图的构建

观察四种不合法情况

发现是如下图中黑色和白色点不能共存,或者割掉红色的一个点

 

拓展到整张图上

 我们发现红色的点相互没有干扰,而黑色和白色的格子对于周围的红格子无法共存

考虑这样建图

1,(S,黑格,花费) (白格,T,花费)

2,(左红格,右红格,min(左红格花费,右红格花费))

3,(黑格,左红格,inf) (右红格,白格,inf)

变成了一个很裸的最小割模型

 

$寿司餐厅$

抽象题意发现是一个依赖模型

又有正负边权,考虑最大权闭合子图

考虑题中的限制关系

1,选$[i,j]$,必须选$[i+1,j]$和$[i,j-1]$

2,负贡献中的cx,可以直接让$b[i][i]$减去$a_{i}$

3,负贡献中的$mx^{2}$,对于每个编号新建一个点,向所有编号为它的点连边

然后按照最大权闭合子图跑就好了

 

III 费用流

就是网络流中的每条边带上费用

把$bfs$改成$spfa$就好了

主要难点在于抽象出费用流的模型以及分层图的构建

$数字配对$

主要难点在于构建分层图

观察相除为一个质数这条要求,可以得到配对的两个数所含质因子个数奇偶性相反

那么我们可以这样构建分层图

1,对每个数分解指因数,个数为奇数的连边$(S,i,b[i],0)$,偶数连边$(i,T,b[i],0)$

2,两层之间能配对的点由奇向偶连边$(i,j,inf,c[i]\times c[j])$

 

$千钧一发$

难点仍然在于构建分层图

我们发现偶数之间满足第二个条件,奇数之间满足第一个条件

这里证明一下两个奇数的平方和不可能是平方数

$\forall a,b(a,b为奇数)$

设$a^{2}+b^{2}=T^{2}$

因为$a^{2}+b^{2}$为偶数,所以$T^{2}$为偶数,所以T为偶数

设$a=2n+1,b=2m+1,T=2p$

$$a^{2}+b^{2}=4p^{2}$$

$$(2n+1)^2+(2m+1)^2=4p^{2}$$

$$4n^{2}+4n+1+4m^{2}+4m+1=4p{2}$$

$$4(n^{2}+n+m^{2}+m)+2=4p^{2}$$

$$n^{2}+n+m^{2}+m+\frac{1}{2}=p^{2}$$

$n^{2}+n+m^{2}+m+\frac{1}{2}=p^{2}$肯定是不成立的

那么我们直接按照奇偶分层,剩下的i就和上一题一样了

 

$无限之环$

咕咕咕

 

IV 上下界网络流

就是网络流中有的边不只有上界还有下界

 无源汇可行流:
  1,建立源汇$ss,tt$
  2,原图中的边 $(u,v,[l,r])$ 变成 $(u,v,r-l)$
  3,统计$in[i]$代表入边的下界和,$out[i]$代表出边下界和
  4,若 $in[i]>out[i]$, 连边$ (ss,i,in[i]-out[i])$,否则建边 $(i,tt,out[i]-in[i])$
  跑最大流, 若满流, 则得到一组可行解, 否则无解

  其中每条边在原图中流量为下界+反向边流量

 有源汇可行流:

  在无源汇基础上新建$(t,s,inf)$就好了

  得到的可行流为$(t,s,inf)$反向边的流量

 源汇最大流:

  拆掉$ss$和$tt$的所有边和$(t,s,inf)$,跑$s->t$最大流

  答案为可行流+最大流

 源汇最小流:

  拆掉$ss$和$tt$的所有边和$(t,s,inf)$,跑$t->s$最大流

 

  答案为可行流-最大流

  有源汇费用流:

  基础答案加上下界$\times$ 费用,其他一样

$矩阵$

首先我们发现这题的答案满足单调性

考虑二分,现在的问题是能否满足当前二分的答案mid

现在的要求是每行每列的总和不能>mid或<-mid

考虑如下建图

1,每行向每列连下界为L上界为R的边

2,起点向每行连下界为$(\sum \limits_{j=1}^{m}a[i][j])-mid$,上界为$(\sum\limits_{j=1}^{m}a[i][j])+mid$的边

3,每列向终点连下界为$(\sum\limits_{i=1}^{n}a[i][j])-mid$,上界为$(\sum\limits_{i=1}^{n}a[i][j])+mid$的边

 

 

Guess you like

Origin www.cnblogs.com/mikufun-hzoi-cpp/p/12019315.html