对于第一问,直接求最大流. 对于第二问,建源点s和汇点t,s连1容量为INF,费用为0的边,n连t容量为最大流+k,费用为0的边.这样就把最大流限制为最多增加k了. 限制需要求扩充的最小费用,原图的边多连一条容量为INF,费用为增容费用K的边.跑一遍费用流即是答案. # include <cstdio> # include <cstring> # include <cstdlib> # include <iostream> # include <vec…
#include<cstdio> #include<iostream> #include<cstring> #define M 100000 #define inf 2139062143 using namespace std; struct data { int l,r,w; }a[M]; *M],u[*M],v[*M],cnt=,n,m,K,ans; ,head1[M],next1[*M],fro[*M],u1[*M],v1[*M],w1[*M],f[M],fr[M…