P3381 【模板】最小费用最大流
模板代码:
/*---------------------------------
*File name: 最小费用最大流.cpp
*Creation date: 2020-05-20 11:56
*-------------------------------*/
#include<queue>
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 5e3 + 5;
const int maxm = 5e4 + 5;
const int inf = 0x3f3f3f3f;
struct Edge{
int to, cost, flow, next;
}edge[maxm << 1];
int head[maxn], cnt = 0;
bool vis[maxn];
int n, m, s, t;
int flow[maxn], cost[maxn];//flow[i]:从源点到i的流量,cost[i]:从源点到i的总花费
int pre[maxn], from[maxn];//pre[i]:值为点,代表i点的前驱点。from[i]:值为边号,连接pre[i]和i的边的序号
inline void Add_Edge(int u, int v, int w, int c){
edge[cnt].n