poj 2239 Selecting Courses
来源:互联网 发布:博弈大师看盘软件 编辑:程序博客网 时间:2024/05/20 02:27
挺裸的二分匹配!
匈牙利算法:
#include<iostream>#include<cstring>#include<cstdlib>using namespace std;int g[305][90];int vis[305];int link[305];int n,m;int dfs(int u){for(int i=1;i<=m;i++)if( !vis[i] && g[u][i] ){vis[i]=1;if( link[i]==-1 || dfs(link[i]) ){link[i]=u;return 1;}}return 0;}int main(){//freopen("in.txt","r",stdin);while(scanf("%d",&n)==1){m=0;memset(g,0,sizeof(g));for(int i=1;i<=n;i++){int a;scanf("%d",&a);for(int j=0;j<a;j++){int x,y;scanf("%d %d",&x,&y);g[i][(x-1)*12+y]=1;if( (x-1)*12+y>m )m=(x-1)*12+y;}}int ans=0;memset(link,-1,sizeof(link));for(int i=1;i<=n;i++){memset(vis,0,sizeof(vis));ans+=dfs(i);}printf("%d\n",ans);}return 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 2239 Selecting Courses
- poj 2239 Selecting Courses
- poj 2239 Selecting Courses 匹配
- POJ 2239:Selecting Courses 选课
- poj 2239 G - Selecting Courses
- POJ 2239 Selecting Courses (二分匹配)
- POJ 2239 Selecting Courses EK!匈牙利!SAP?
- android定时服务实现的相关开源包
- ORA-00600 [krctcr_4]
- 在Linux上删除大容量文件后硬盘空间大小还不变,解决办法
- 【C++】顺序容器 Vector 注意事项
- mecgrid 的样式测试
- poj 2239 Selecting Courses
- web.xml 中的listener、 filter、servlet 加载顺序及其详解
- 黑马程序员_内部类和包
- RTP与RTCP协议介绍
- android 项目实训—贪吃蛇Snake(一)
- 快速排序的汇编级优化(windowds平台VS下dubug release模式对比 linux平台gcc的有无优化对比)
- iBatis SqlMap的配置总结
- C# 窗体间传值方法大汇总
- 如何做APP界面设计