poj 2239 Selecting Courses 二分图最大匹配
来源:互联网 发布:游戏中的算法 编辑:程序博客网 时间:2024/05/01 20:20
题意:
裸的二分图最大匹配。
思路:
直接用匈牙利算法的模板即可。
代码:
//poj 2239//sepNINE#include<iostream>using namespace std;const int maxN=302; int M,v1,v2;bool g[maxN][maxN];bool vis[maxN];int link[maxN];bool dfs(int x){for(int y=1;y<=v2;++y)if(g[x][y]&&!vis[y]){vis[y]=true;if(link[y]==0||dfs(link[y])){link[y]=x;return true;}}return false;}void hungary(){for(int x=1;x<=v1;++x){memset(vis,false,sizeof(vis));if(dfs(x))++M;}return ;}int main(){int n;while(scanf("%d",&n)==1){memset(g,false,sizeof(g));memset(link,0,sizeof(link));int i,maxV1=-1;for(i=1;i<=n;++i){int x;scanf("%d",&x);while(x--){int a,b,c;scanf("%d%d",&a,&b);c=a*13+b;maxV1=max(maxV1,c);g[c][i]=1;}}M=0;v1=maxV1;v2=n;hungary();printf("%d\n",M);}return 0;}
0 0
- poj 2239 Selecting Courses 二分图最大匹配数
- poj 2239 Selecting Courses 二分图最大匹配
- Poj 2239 Selecting Courses 二分图最大匹配
- POJ 2239 Selecting Courses(二分图最大匹配)
- POJ 2239 Selecting Courses(二分图最大匹配)
- poj 2239 Selecting Courses 二分图最大匹配
- POJ 2239-Selecting Courses(二分图_最大匹配+哈希建图)
- poj 2239 Selecting Courses 【二分图最大匹配】
- POJ - 2239 Selecting Courses 二分图 最大匹配
- POJ 2239--Selecting Courses【二分图 && 最大匹配数 && 水题】
- POJ 2239 Selecting Courses(二分图最大匹配)
- poj Selecting Courses 2239 (二分图最大匹配)
- POJ 2239 Selecting Courses(二分图最大匹配)
- POJ-2239 Selecting Courses(二分图最大匹配)
- POJ 2239 - Selecting Courses(二分图匹配)
- poj Selecting Courses(二分图最大匹配)
- POJ 2239Selecting Courses(二分图最大匹配之最大匹配)
- poj 2239 Selecting Courses(二分图最大匹配or最大流)
- QUICK COCOS2D-X 触摸事件
- 美国大学计算机工程专业TOP10
- 题目1021:统计字符
- 4Sum
- 第12周项目1--阅读程序(1、静态局部变量)
- poj 2239 Selecting Courses 二分图最大匹配
- UVa 147 - Dollars
- 基站使用api说明
- 第十二周项目 1 阅读程序(静态变量)
- globalmem.c:193:2: 错误:隐式声明函数‘kmalloc’ [-Werror=implicit-function-declaration]
- 黑马程序员 学习日志06 数组以及逻辑运算符
- 数据预处理之数据描述
- java hashMap和TreeMap区别深入理解
- fancybox例子