poj1466
来源:互联网 发布:数据库有5个事务 编辑:程序博客网 时间:2024/06/11 20:02
#include <iostream>#include<cstdio>#include<algorithm>#include<vector>#include<cstring>using namespace std;const int MAX=505;int n,match[MAX],used[MAX];vector<int> g[MAX];bool dfs(int v){ used[v]=true; for(int i=0;i<g[v].size();i++) { int &u=g[v][i],w=match[u]; if(w<0||!used[w]&&dfs(w)) { match[v]=u; match[u]=v; return true; } } return false;}int matching(){ int ans=0; memset(match,-1,sizeof(match)); for(int v=0;v<n;v++) { if(match[v]<0) { memset(used,0,sizeof(used)); if(dfs(v)) ans++; } } return ans;}int main(){ while(cin>>n) { for(int i=0;i<MAX;i++) g[i].clear(); int u,v,num; for(int i=0;i<n;i++) { scanf("%d: (%d)",&u,&num); for(int j=0;j<num;j++) { scanf("%d",&v); g[u].push_back(v); } } cout<<n-matching()<<endl; } return 0;}最大独立集
0 0
- poj1466
- poj1466
- poj1466
- poj1466
- POJ1466
- poj1466
- 匈牙利算法之POJ1466
- poj1466 - Girls and Boys
- poj1466最大独立集
- poj1466--Girls and Boys
- POJ1466 Girls and Boys
- poj1466 Girls and Boys
- 最大独立集 poj1466
- POJ1466 Girls and Boys
- POJ1466-Girls and Boys
- hdu1068||poj1466(最大独立集)
- poj1466最大二分图匹配
- ZOJ1137&&POJ1466-Girls and Boys
- ASP.NET一款免费富文本(RichText)编辑器KindEditor,实现在线排版编辑文章。这里简单介绍下如何使用
- 1003. Emergency (25)
- 1004. Counting Leaves (30)
- 杭电---2053 Switch Game
- LeetCode[172]Factorial Trailing Zeroes
- poj1466
- 1005. Spell It Right (20)
- 学分平均绩计算方法
- Struts2学习笔记一
- hasOwnProperty()与for in的区别
- 静态变量中的两种两种取出方式self和对象取值
- 引用导出类后类初始化顺序
- cf Round #276 (Div. 2) D. Maximum Value
- OC程序设计中的单例模式