HDU 1274 The Perfect Stall(二分图匹配)
来源:互联网 发布:算法第四版英文版pdf 编辑:程序博客网 时间:2024/06/04 20:04
模版题,wa了一次因为忘记每次都初始化vis数组了。
#include <iostream>#include <cstring>#include <cstdlib>#include <cstdio>#include <algorithm>#define LL long long#define FOR(i, x, y) for(int i=x;i<=y;i++)using namespace std;const int MAXN = 200 + 10;int G[MAXN][MAXN];int vis[MAXN];int match[MAXN];int n, m;int path(int u){ for(int v=1;v<=m;v++) { if(G[u][v] && !vis[v]) { vis[v] = 1; if(match[v] == -1 || path(match[v])) { match[v] = u; return 1; } } } return 0;}int main(){ while(scanf("%d%d", &n, &m)!=EOF) { memset(G, 0, sizeof(G)); for(int i=1;i<=n;i++) { int x; scanf("%d", &x); while(x--) { int t; scanf("%d", &t); G[i][t] = 1; } } memset(match, -1, sizeof(match)); int ans = 0; for(int i=1;i<=n;i++) { memset(vis, 0, sizeof(vis)); ans += path(i); } printf("%d\n", ans); } return 0;}
0 0
- HDU 1274 The Perfect Stall(二分图匹配)
- 【POJ】1274 The Perfect Stall 二分匹配
- Poj 1274 The Perfect Stall【二分匹配】
- USACO: the perfect stall 二分图匹配
- (二分图最大匹配)The Perfect Stall
- poj1274 The Perfect Stall(二分图匹配)
- poj1274 The Perfect Stall【二分图匹配】
- POJ 1274 The Perfect Stall 二分图最大匹配
- 二分图匹配(简单题)POJ 1274 The Perfect Stall
- 二分图最大基数匹配 POJ 1274 The Perfect Stall
- POJ 1274 The Perfect Stall(二分图最大匹配)
- 【二分图+最大匹配】北大 poj 1274 The Perfect Stall
- POJ 1274 The Perfect Stall 【二分图匹配】
- poj 1274 The Perfect Stall (二分图匹配)
- Poj 1274 The Perfect Stall[二分图最大匹配]
- POJ 1274The Perfect Stall(二分图最大匹配)
- POJ 1274 The Perfect Stall 二分图最大匹配
- POJ 1274 The Perfect Stall(二分图最大匹配)
- 好记性不如烂笔头75-多线程-并行访问下的资源竞争和样例
- java图形记事本01
- JAVA集合总结
- zynq 网上资料
- iOS开发 根据日期计算是星期几
- HDU 1274 The Perfect Stall(二分图匹配)
- 使用字节流及缓存字节流读取、写入和拷贝文件
- hash的利用
- crontab命令
- HDU 2328 Corporate Identity
- Overlay网络与物理网络的关系-屈寸 王长强(Overlay 网络)
- cxgrid行,列颜色控制
- 观察者模式
- 操作系统之VMware workspace中安装Ubuntu