版本比较
上下界网络流模板汇总
正文
增加 8 行删除 8 行
104 行未改动全部展开10510610710810910911011111211382 行未改动19619719819920020020120220320480 行未改动28528628728828928929029129229320 行未改动31431531631731831831932032132232332332432532632732832933033133133233333433531 行未改动3673683693703713713723733743755 行未改动38138238338438538538638738838921 行未改动104 行未改动全部展开 else{ cout<<"Yes\n"; for(int i=2;i<(m+1)*2;i+=2) cout<<e[i].l+e[i^1].c<<'\n'; } return 0; return 0;}```### Sub2:[有源汇上下界最大流](https://www.luogu.com.cn/problem/P14579)
82 行未改动 int k=e[tot].c; e[tot-1].c=e[tot].c=0; cout<<dinic(s,t)+k<<'\n'; } return 0; return 0;}```### Sub3:[有源汇上下界最小流](https://www.luogu.com.cn/problem/P14580)
80 行未改动 int k=e[tot].c; e[tot-1].c=e[tot].c=0; cout<<k-dinic(t,s)<<'\n'; } return 0; return 0;}```
### 例题:[东方文花帖](https://www.luogu.com.cn/problem/P5192)20 行未改动void add(int from,int to,int c){ e[++tot]={to,head[from],c}; head[from]=tot; e[++tot]={from,head[to],0}; head[to]=tot; head[to]=tot;}bool bfs(int s,int t){ queue<int>q; memset(dep,0,sizeof(dep)); q.push(s); dep[s]=1; q.push(s); dep[s]=1; while(!q.empty()){ int tmp=q.front(); q.pop(); for(int i=head[tmp];i;i=e[i].next){ int v=e[i].to; if(!dep[v]&&e[i].c){ dep[v]=dep[tmp]+1; q.push(v); } } } if(tmp==t) return true; } return false;31 行未改动 for(int i=1,g,p;i<=m;i++){ cin>>g; p=n+i; add(p,t,INF-g); //[g,INF] in[t]+=g,in[p]-=g; in[t]+=g,in[p]-=g; } for(int i=1,c,d;i<=n;i++){ cin>>c>>d; add(s,i,d); //[0,d]5 行未改动 } } for(int i=0;i<=n+m+1;i++){ if(in[i]>0){ add(SS,i,in[i]); add(SS,i,in[i]); outflow+=in[i]; } else if(in[i]<0) add(i,TT,-in[i]); }21 行未改动