hdu 1068 Girls and Boys 二分图的最大匹配
2015-08-11 20:49
465 查看
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1068
#include <iostream> #include <stdio.h> #include <string.h> using namespace std; int n; int used[505]; int link[505][505]; int boy[505]; int find(int x){ int i; for(i=0;i<n;i++){ if(!used[i]&&link[x][i]){ used[i]=1; if(boy[i]==0||find(boy[i])){ boy[i]=x; return true; } } } return false; } int main() { int all; int t,per,i,num; while(scanf("%d",&n)!=EOF){ memset(link,0,sizeof(link)); memset(boy,0,sizeof(boy)); all=0; for(i=0;i<n;i++){ scanf("%d: (%d)",&t,&num); while(num--){ scanf("%d",&per); link[t][per]=1; } } for(i=0;i<n;i++){ memset(used,0,sizeof(used)); all+=find(i); } printf("%d\n",n-all/2); } return 0; }
相关文章推荐
- 线程和进程
- C#高级编程---暂停计划
- [Linux]结合awk删除hdfs指定日期前的数据
- Android 签名工具 shell脚本
- bad ELF interpreter
- java学习之数组(一)
- lftp复制文件及镜像
- Spring框架中读取xml文件的两种不同方式
- Codeforces Round #315 (Div. 2)
- 用Java的HttpClient写一个简单的http请求和返回
- 平面点曼哈顿最小生成树——POJ 3241 Object Clustering
- HDU 5373 The shortest problem //模拟
- "performSelector may cause a leak because its selector is unknown"警告原因及其解决办法
- 优雅地对泛型List 进行深拷贝
- 对exp full 和 imp full的认识
- How to create VO s and VLs dynamically in OAF
- POI教程之第一讲:创建新工作簿, Sheet 页,创建单元格
- 原型模式、模板模式
- Java基础---抽象类和接口
- Hadoop学习1_在使用命令行运行WordCount时,遇到的jar命令说明