点击打开链接
多源多汇最大流,虚拟一个源点s'和一个汇点t',原来的源点、汇点向它们连边。
#include<cstdiO>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
const int maxn = 500 + 5;
const int INF = 100000000;
struct Edge{
int from, to, cap, flow;
};
struct Dinic{
int n, m, s, t;
vector<Edge> edges;
vector<int> G[maxn];
bool vis[maxn];
int d[maxn];
i......
阅读全文