摘要: 题目链接算是一个模版题把。构造一个源点和汇点,所有的核电站都是从源点出发的,所有的用户都汇集到汇点,跑一次最大流就可以了。模版敲的不是很熟。 1 #include <cstdio> 2 #include <cstring> 3 #include <queue> 4 using namespace std; 5 const int INF = 0xffffff; 6 int flow[201][201],low[201],path[201]; 7 int str,end,n; 8 int bfs() 9 {10 int t,i;11 queue<int& 阅读全文
posted @ 2012-12-11 16:55 Naix_x 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 题目链接无向二分图的最小路径覆盖 = 顶点数 – 最大二分匹配数/2看题解过的。看了网上的题解,说是拆点,然后把所有的城市分为两个集合,然后用匈牙利算法计算出最大二分图匹配。 1 #include <cstdio> 2 #include <cstring> 3 using namespace std; 4 char str[51][51]; 5 int p[501][501],used[501],linker[501],o[51][51]; 6 int x[4] = {0,0,1,-1}; 7 int y[4] = {1,-1,0,0}; 8 int num; 9 in 阅读全文
posted @ 2012-12-11 16:01 Naix_x 阅读(122) 评论(0) 推荐(0) 编辑