HDU 1150(最小点覆盖)
来源:互联网 发布:python运行原理 编辑:程序博客网 时间:2024/05/18 01:50
题意:经典的机器调度问题。
在二分图G=(X,Y;E)中求取最少的顶点集v*(在{X,Y}中找),使得边ei (属于E)都和至少一个顶点vi(属于v*)相关联。这就是二分图模型中的最小顶点覆盖问题。
最小点覆盖==二分图最大匹配。
#include <iostream>using namespace std;const int maxn=110;int map[maxn][maxn];int vis[maxn];int n,m,k,x,y,link[maxn];int path(int u){ for(int v=1;v<m;v++) { if(map[u][v]&&!vis[v]) { vis[v]=1; if(link[v]==-1||path(link[v])) { link[v]=u; return 1; } } } return 0;}int MaxMatch(){ int res=0; memset(link,-1,sizeof(link)); for(int i=1;i<n;i++) { memset(vis,0,sizeof(vis)); if(path(i)) res++; } return res;}int main(){ int j; while(cin>>n&&n) { memset(map,0,sizeof(map)); cin>>m>>k; while(k--) { cin>>j>>x>>y; if(x!=0&&y!=0)// 看题目这一句At the beginning they are both work at mode_0. map[x][y]=1; } cout<<MaxMatch()<<endl; } return 0;}
0 0
- HDU 1150(最小点覆盖)
- hdu 1150 最小点覆盖
- HDU 1150 Machine Schedule 最小点覆盖
- hdu 1150 Machine Schedule ( 最小点覆盖 )
- hdu 1150 Machine Schedule (最小点覆盖)
- HDU 1150 Machine Schedule (最小点覆盖)
- hdu 1150 Machine Schedule(最小点覆盖)
- HDU 1150 Machine Schedule(最小点覆盖)
- hdu 1150 Machine Schedule 最小点覆盖
- hdu 1150 最小点覆盖 Machine Schedule
- hdu 1150(最小点覆盖)
- hdu 1054 最小点覆盖
- hdu 1054 最小点覆盖
- 最小点覆盖 hdu--1054
- HDU 1150 Machine Schedule(最小点覆盖问题)
- hdu 1150 二分图 最小点覆盖=最大匹配
- HDU 1150 二分图匹配 最小点覆盖
- HDU 1150 二分图匹配 最小点覆盖
- 个人笔记 #pargma pack()命令
- exit()和_exit()
- 移动类型数量更新价值不更新
- printf背后的故事
- ORACLE MAX对CHAR类型的特殊处理(V10.2.0.1.0)
- HDU 1150(最小点覆盖)
- linux vim 使用方法 练级攻略
- 求连续子数组的最大和
- MyEclipse中调试Tomcat
- java 类对象引用关系
- android入门:zxing学习笔记
- oracle 解锁及密码过期问题
- J2EE——JDBC
- 通用makefile是如何炼成的(XI)--最后的完结篇,envsetup.sh