poj 2239 Selecting Courses 最大二分匹配
2011-01-29 21:44
302 查看
把p,q化为一维之后,直接用匈牙利算法
#include<iostream> using namespace std; const int MAX = 200; bool arcs[MAX][MAX]; int match[MAX]; bool isvisit[MAX]; int n, m = 7*12; int find(int u) { for (int i = 1; i <= m; i++) if (arcs[u][i] && !isvisit[i]) { isvisit[i] = true; if (!match[i] || find(match[i])) { match[i] = u; return true; } } return false; } int main() { int t, p, q; while (cin >> n) { memset(arcs, false, sizeof(arcs)); memset(match, 0, sizeof(match)); for (int j = 1; j <= n; j++) { cin >> t; for (int i = 1; i <= t; i++) { cin >> p >> q; arcs[j][12*(p-1) + q] = true; } } int ans = 0; for (int i = 1; i <= n; i++) { memset(isvisit, false, sizeof(isvisit)); if (find(i)) ans++; } cout << ans << endl; } return 0; }
相关文章推荐
- POJ 2239 Selecting Courses 最大二分匹配
- POJ 2239 二分最大匹配
- poj 2239 二分 最大匹配
- poj 1325 Machine Schedule 二分匹配,可以用最大流来做
- POJ 2112 Optimal Milking (二分+最短路+最大流or二分图多重匹配)
- POJ 2239 Selecting Courses (二分匹配)
- poj 3020 二分最大匹配
- poj 2239 Selecting Courses 【二分图最大匹配】
- poj 2536 Gopher II 最大二分匹配
- poj 匈牙利二分匹配算法2239 Selecting Courses
- poj 2446 Chessboard (最大二分匹配)
- HLG 1392 (POJ 2112 Optimal Milking)【二分+二分图多重匹配 + 最大流】
- POJ 1087 A Plug for UNIX(网络流—最大流(最大二分匹配))
- POJ 3216 二分匹配(想到就简单的题) floyed求最短路+匈牙利最大匹配
- poj2239 Selecting Courses --- 二分图最大匹配
- POJ 2112 Optimal Milking (二分+最大流/多重匹配) && POJ 2391 Ombrophobic Bovines( 二分+拆点+最大流)
- POJ 2771 Guardian of Decency(二分匹配,最大独立集)
- POJ 3020 最小路径覆盖 = 顶点数-最大匹配数 二分匹配
- POJ 1274 The Perfect Stall(二分匹配 最大匹配数)
- POJ1034最大二分匹配