#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
using namespace std; #define MAXN 500
int map[MAXN][MAXN];
int mark[MAXN];
int pipei[MAXN];
int n; int search(int a)
{
for (int i = ; i < n; i++)
{
if (map[a][i] && !mark[i])
{
mark[i] = ;
if (pipei[i] == - || search(pipei[i]))
{
pipei[i] = a;
return ;
}
}
} return ;
} int main()
{
while (~scanf("%d",&n))
{
memset(map, , sizeof(map));
int m;
for (int i = ; i <n; i++)
{
int y;
scanf("%d: (%d)", &m, &y);
for (int i = ; i < y; i++)
{
int a;
scanf("%d", &a);
map[m][a] = ;
}
} memset(pipei, -, sizeof(pipei));
int ans1 = ;
for (int i = ; i < n; i++)
{
memset(mark, , sizeof(mark));
if (search(i))
ans1++;
}
printf("%d\n", n - ans1/);
}
//system("pause");
return ;
}

hdu1068 Girls and Boys 基础匈牙利的更多相关文章

  1. hdoj 1068 Girls and Boys【匈牙利算法+最大独立集】

    Girls and Boys Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  2. Girls and Boys(匈牙利)

    Girls and Boys Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  3. hdu 1068 Girls and Boys(匈牙利算法求最大独立集)

    Girls and Boys Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  4. hdu1068 Girls and Boys 匈牙利算法(邻接表)

    #include <cstdio> #include <algorithm> #include <cstring> #include <vector> ...

  5. hdu1068 Girls and Boys

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1068 二分图的最大独立集数=节点数(n)— 最大匹配数(m) 另外需要注意的是: 本题求出的最大匹配数是实 ...

  6. hdu1068 Girls and Boys 二分匹配

    题目链接: 二分匹配的应用 求最大独立集 最大独立集等于=顶点数-匹配数 本体中由于男孩和女孩的学号是不分开的,所以匹配数应是求得的匹配数/2 代码: #include<iostream> ...

  7. hdu1068 Girls and Boys --- 最大独立集

    有一个集合男和一个集合女,给出两集合间一些一一相应关系.问该两集合中的最大独立集的点数. 最大独立集=顶点总数-最大匹配数 此题中.若(a,b)有关.则(b,a)有关.每个关系算了两次,相当于二分图的 ...

  8. POJ 1466 Girls and Boys (匈牙利算法 最大独立集)

    Girls and Boys Time Limit: 5000MS   Memory Limit: 10000K Total Submissions: 10912   Accepted: 4887 D ...

  9. HDU 1068 Girls and Boys 二分图最大独立集(最大二分匹配)

    Girls and Boys Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

随机推荐

  1. Django-配置celery

    首先需要安装的包 pip install cellerypip install django-cellery pip install django-cellery-results pip instal ...

  2. Robot Framework自己主动化測试框架之我见

    一些自己主动化測试现状: 盲目的去做自己主动化,终于以失败告终. 觉得是能提高效率的事情.却推广不下去: 事实上上述问题产生的原因是: 自己主动化測试案例稳定性不高,可维护性比較差: 自己主动化測试工 ...

  3. MD5加密实现类不是Windows平台下联邦信息处理标准验证过的加密算法的一部分

    在.NET应用程序中,MD5CryptoServiceProvider实例化时,造成This implementation is not part of the Windows Platform FI ...

  4. hive增加Update、Delete支持

    一.配置hive-site.xml二.建表三.操作四.总结 一.配置hive-site.xml CDH版本先进入Hive配置页 选择高级,找到hive-site.xml 的 Hive 客户端高级配置代 ...

  5. bash shell中的特殊用法

    1 ${BASH_SOURCE-$0} 表示当前正在执行的脚本的完整路径. 2 cd -P 以物理路径进入 /usr/localhadoop现在链到/home/houzhizhen/usr/local ...

  6. Understanding When to use RabbitMQ or Apache Kafka Kafka RabbitMQ 性能对比

    Understanding When to use RabbitMQ or Apache Kafka https://content.pivotal.io/rabbitmq/understanding ...

  7. top load average

    负载均值 等待运行的进程数

  8. Mac开发必备工具(二)—— iTerm 2

    iTerm 2 简介 iTerm 2 is a terminal emulator for Mac OS X that does amazing things. iTerm 2 有很多能够提升效率的实 ...

  9. 一个实用的UIView的类别

    // // FrameAccessor.h // FrameAccessor // // Created by Alex Denisov on 18.03.12. // Copyright (c) 2 ...

  10. model.js

    var Model = { inherited: function () {}, created: function () {}, prototype: { init: function (attrs ...