【网络流24题】负载平衡问题
这又是一道我没有当场想出来的题 题面 https://www.luogu.org/problemnew/show/P4016 题解 $S$连初始状态,末状态连$T$,转移边流量为$INF$,费用为$1$。 #include<cstdio> #include<cstring> #include<iostream> #include<vector> #include<queue> #define N 105 #define INF 1000000007 #define T (n+1) #define S 0 #define LL long long #define ri register int using namespace std; int n,a[N]; struct graph { vector<int> to,w,c; vector<int> ed[N]; LL dis[N]; int cur[N]; bool vis[N]; void add_edge(int a,int b,int aw,int ac) { to.push_back(b); w.push_back(aw); c.push_back(ac); ed[a].push_back(to.size()-1); to.push_back(a); w.push_back(0); c.push_back(-ac); ed