摘要: 题目链接拆点+KM,建图思路看的题解。。。看懂的题意后,想了好一会。知道这题是KM,但是不会建图,无奈啊。建图很巧妙,假如同一个机器上加工了k件物品,那么实际花费时间k*a1+(k-1)*a2+(k-3)*a3....其实对这个拆点,也不是很懂。这样把m个机器拆成n个点,表示是第几个加工的。套上模版,这题是求最小权,取一下相反数就行了。拆成两个集合一个存n个物品,另一个存第i个机器上第j个加工。 1 #include <iostream> 2 #include <cstring> 3 #include <string> 4 #include <cstd 阅读全文
posted @ 2013-04-17 21:15 Naix_x 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 题目链接最大的二分图带权匹配,KM算法模版题,抄的别人的。 1 #include <iostream> 2 #include <cstring> 3 #include <string> 4 #include <cstdio> 5 using namespace std; 6 #define N 301 7 #define INF 0x7fffffff 8 int mat[N][N]; 9 int match[N];10 int inx[N],iny[N];11 int lx[N],ly[N];12 int n;13 int dfs(int u)1 阅读全文
posted @ 2013-04-17 19:03 Naix_x 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 第一个最小割,理解了好一会。实数的最大流,注意eps,然后把乘法取log后变为加法。 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <queue> 5 using namespace std; 6 #define eps 1e-8 7 #define INF 0x3f3f3f3f 8 int dis[201],first[201]; 9 int n,m,t; 10 struct node 11 { 12 int u,v,next,re; 13 doub 阅读全文
posted @ 2013-04-17 14:49 Naix_x 阅读(158) 评论(2) 推荐(0) 编辑