P4843 清理雪道(上下界网络流)
P4843 清理雪道 上下界最小流 我们先搞一遍 上下界可行流(转) 回忆上下界最大流的写法:在可行流的残量网络$s\ -\ t$上跑最大流,答案为可行流$+$残量网络的最大流 那么上下界最小流的写法呢? 只要在残量网络$t\ -\ s$上跑最大流,答案就是可行流$-$残量网络$t\ -\ s$的最大流辣 #include<iostream> #include<cstdio> #include<cstring> #include<queue> using namespace std; #define N 1005 #define M 1000005 const int inf=2e9; int n,S,T,pS,pT,ex[N],d[N],cur[N]; queue <int> h; bool vis[N]; int cnt=1,hd[N],nxt[M],ed[N],poi[M],val[M],fr[M]; inline void adde(int x,int y,int v){ nxt[ed[x]]=++cnt, hd[x]=hd[x]?hd[x]:cnt, ed[x]=cnt, poi[cnt]=y, val[cnt]=v, fr[cnt]=x; } inline void link(int x,int y,int v){adde(x,y,v),adde(y,x,0);}