View Code #define MIN(a,b) ((a)<(b)?(a):(b))#define INF 999999#define MAX 5110int n,match[MAX];bool sx[MAX],sy[MAX];int lx[MAX],ly[MAX],map[MAX][MAX];bool path(int u){ sx[u]=true; for(int v=0;v<n;v++) if(!sy[v]&&lx[u]+ly[v]==map[u][v]) { sy[v]=true; if(match... Read More
posted @ 2012-03-26 11:41 Because Of You Views(776) Comments(0) Diggs(0) Edit
找出若干个环覆盖所有的点,使得总的花费最小因为每个点只能经过一次,所以很快就可想到拆点求最小费用流建图:S->i 费用为0 流量为1i+n->T同上若有边u->vu->v+n 费用为边权,容量为1最后套套模板求一次最小费用流,如果流量等于n,表示每个点都遍历了一次,输出最小费用即可View Code #include <iostream>#include <algorithm>#include <string>#include <stdio.h>#include <string.h>#include <s Read More
posted @ 2012-03-26 11:20 Because Of You Views(861) Comments(0) Diggs(0) Edit
从网上找的模板,测试了一下View Code #include <iostream>#include <algorithm>#include <string>#include <stdio.h>#include <string.h>#include <stdlib.h>#include <memory.h>#include <queue>#include <vector>#include <cmath>using namespace std;int sumFlow;const Read More
posted @ 2012-03-26 11:14 Because Of You Views(817) Comments(0) Diggs(0) Edit