Girls and Boys

          Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
              Total Submission(s): 12246    Accepted Submission(s): 5768

Problem Description
the second year of the university somebody started a study on the romantic relations between the students. The relation “romantically involved” is defined between one girl and one boy. For the study reasons it is necessary to find out the maximum set satisfying the condition: there are no two students in the set who have been “romantically involved”. The result of the program is the number of students in such a set.

The input contains several data sets in text format. Each data set represents one set of subjects of the study, with the following description:

the number of students
the description of each student, in the following format
student_identifier:(number_of_romantic_relations) student_identifier1 student_identifier2 student_identifier3 ...
or
student_identifier:(0)

The student_identifier is an integer number between 0 and n-1, for n subjects.
For each given data set, the program should write to standard output a line containing the result.

 
Sample Input
7
0: (3) 4 5 6
1: (2) 4 6
2: (0)
3: (0)
4: (2) 0 1
5: (1) 0
6: (2) 0 1
3
0: (2) 1 2
1: (1) 0
2: (1) 0
 
Sample Output
5
2
 
Source
 
 
二分图的最大匹配数(裸题)
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define N 1010
using namespace std;
bool vis[N];
int t,n,m,x,y,ans,girl[N],map[N][N];
int read()
{
    ,f=; char ch=getchar();
    ; ch=getchar();}
    +ch-';ch=getchar();}
    return x*f;
}
int find(int x)
{
    ;i<=n;i++)
    {
        if(!vis[i]&&map[x][i])
        {
            vis[i]=true;
            ||find(girl[i])) {girl[i]=x;;}
        }
    }
    ;
}
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        ans=;
        memset(map,,sizeof(map));
        memset(girl,-,sizeof(girl));
        ;i<=n;i++)
        {
            x=read();m=read();
            while(m--)
              y=read(),map[x+][y+]=;
        }
        ;i<=n;i++)
        {
            memset(vis,,sizeof(vis));
            ans+=find(i);
        }
        printf(*n-ans)/);
    }
    ;
}

HDU——1068 Girls and Boys的更多相关文章

  1. HDU 1068 Girls and Boys(最大独立集合 = 顶点数 - 最大匹配数)

    HDU 1068 :题目链接 题意:一些男孩和女孩,给出一些人物关系,然后问能找到最多有多少个人都互不认识. 转换一下:就是大家都不认识的人,即最大独立集合 #include <iostream ...

  2. HDU 1068 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. hdu 1068 Girls and Boys(匈牙利算法求最大独立集)

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

  5. hdu 1068 Girls and Boys (最大独立集)

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

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

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1068 有n个同学,格式ni:(m) n1 n2 n3表示同学ni有缘与n1,n2,n3成为情侣,求集合 ...

  7. [HDU] 1068 Girls and Boys(二分图最大匹配)

    题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1068 本题求二分图最大独立点集.因为最大独立点集=顶点数-最大匹配数.所以转化为求最大匹配.因为没有给 ...

  8. hdu 1068 Girls and Boys 最大独立点集 二分匹配

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1068 思路: 求一集合满足,两两之间没有恋爱关系 思路: 最大独立点集=顶点数-最大匹配数 这里给出的 ...

  9. HDU 1068 Girls and Boys(模板——二分图最大匹配)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1068 Problem Description the second year of the univ ...

随机推荐

  1. 手写一套迷你版HTTP服务器

    本文主要介绍如何通过netty来手写一套简单版的HTTP服务器,同时将关于netty的许多细小知识点进行了串联,用于巩固和提升对于netty框架的掌握程度. 服务器运行效果 服务器支持对静态文件css ...

  2. Mac OS 下安装和配置 maven

    1. 安装 Maven 前的必须准备 需先安装 Java 环境 下载合适的 JDK 配置 JDK 环境变量 JAVA_HOME:为 JDK 安装目录 Path:为 JDK/bin 目录 测试是否成功: ...

  3. windows系统同时安装多个nodejs环境(一键切换)

    由于不同程序对nodejs的环境要求不同,从而导致在单台电脑上开发多个nodejs应用很烦人: 好在gnvm,这个家伙帮我解决了问题 官网: https://github.com/kenshin/gn ...

  4. Redux中的异步操作

    异步操作的另一种方案就是让Action Creator返回一个Promise对象. 我们这边使用  redux-promise  中间件 import { createStore, applyMidd ...

  5. 浅谈网上的zoomlistview存在的问题

    最近项目主要是做一个类似wps文档阅历的功能,以列表的形式显示文档,并且需要实现缩放平移.而网上关于此类功能的实现主要是通过自定义的listview实现的,类名为ZoomListView. 网上的zo ...

  6. 解决hibernate对Sql Server分页慢的问题

    一.hibernate分页 hibernate对MsSql的伪分页 分页是web项目中比不可少的一个功能,数据量大的时候不能全部展示必然要用到分页技术.相信大家对hibernate中的分页都不陌生: ...

  7. leetcode_650. 2 Keys Keyboard_dp

    https://leetcode.com/problems/2-keys-keyboard/ 初始一个A,两种操作,复制当前所有A,粘贴,问得到n个A最少需要多少步操作. class Solution ...

  8. Flask框架 之上下文、请求钩子与Flask_Script

    一.上下文 请求上下文:request与session 应用上下文:current_app与g:一次请求多个函数可以用它传参 @app.route("/") def index() ...

  9. mysql 优化策略

    from:https://dbaplus.cn/news-155-1531-1.html MySQL逻辑架构 如果能在头脑中构建一幅MySQL各组件之间如何协同工作的架构图,有助于深入理解MySQL服 ...

  10. JavaSE-15 Log4j参数详解

    一:日志记录器输出级别,共有5级(从前往后的顺序排列) ①fatel:指出严重的错误事件将会导致应用程序的退出 ②error:指出虽然发生错误事件,但仍然不影响系统的继续运行 ③warn:表明会出现潜 ...