最大流裸题,有向图,然后又重边,容量要累加,这里是用BFS来做的
#include#include #include using namespace std;#define INF 0x3f3f3f3f#define N 20queue q;int f[N][N],c[N][N],a[N],p[N],flow;int n,m;//源点和汇点分别规定为1,nvoid BFS(){ flow=0; while(1) { memset(a,0,sizeof(a)); a[1]=INF; while(!q.empty()) q.pop(); q.push(1); while(!q.empty()) { int u; u=q.front(); q.pop(); for(int v=1; v<=n; v++) if(!a[v] && c[u][v]>f[u][v]) { p[v]=u; q.push(v); a[v]=a[u]