#include<stdio.h>

#include<string.h>

#define N 300

#define inf 0x3fffffff

int mark[N],link[N],n,m;

int map[N][N];

int find(int u) {

int i;

for(i=1;i<=m;i++) {

    if(!mark[i]&&map[u][i]) {

        mark[i]=1;

        if(link[i]==-1||find(link[i])) {

            link[i]=u;

            return 1;

        }

    }

}

return 0;

}

int main() {

    int i,k,s,t;

    while(scanf("%d%d",&n,&m)!=EOF) {

        memset(map,0,sizeof(map));

        memset(link,-1,sizeof(link));

        for(i=1;i<=n;i++) {

            scanf("%d",&s);

            while(s--) {

                scanf("%d",&t);

                map[i][t]=1;

            }

        }

        k=0;

    for(i=1;i<=n;i++) {

        memset(mark,0,sizeof(mark));

        k+=find(i);

    }

    printf("%d\n",k);

    }

return 0;

}

poj 1274 基础二分最大匹配的更多相关文章

  1. POJ 1274 The Perfect Stall、HDU 2063 过山车(最大流做二分匹配)

    The Perfect Stall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24081   Accepted: 106 ...

  2. Luogu 1894 [USACO4.2]完美的牛栏The Perfect Stall / POJ 1274 The Perfect Stall(二分图最大匹配)

    Luogu 1894 [USACO4.2]完美的牛栏The Perfect Stall / POJ 1274 The Perfect Stall(二分图最大匹配) Description 农夫约翰上个 ...

  3. POJ 3041 Asteroids(模板——二分最大匹配(BFS增广))

    题目链接: http://poj.org/problem?id=3041 Description Bessie wants to navigate her spaceship through a da ...

  4. hdu2063 匈牙利算法 二分最大匹配模版题

    过山车 Time Limit: 1000 MS Memory Limit: 32768 KB 64-bit integer IO format: %I64d , %I64u Java class na ...

  5. poj 2318 叉积+二分

    TOYS Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 13262   Accepted: 6412 Description ...

  6. poj 2049(二分+spfa判负环)

    poj 2049(二分+spfa判负环) 给你一堆字符串,若字符串x的后两个字符和y的前两个字符相连,那么x可向y连边.问字符串环的平均最小值是多少.1 ≤ n ≤ 100000,有多组数据. 首先根 ...

  7. poj——1274 The Perfect Stall

    poj——1274   The Perfect Stall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 25709   A ...

  8. hdu 2444 交叉染色判断二分图+二分最大匹配

    /*1A 31ms*/ #include<stdio.h> #include<string.h> #define N 300 int n; struct node { int ...

  9. POJ 1274 The Perfect Stall || POJ 1469 COURSES(zoj 1140)二分图匹配

    两题二分图匹配的题: 1.一个农民有n头牛和m个畜栏,对于每个畜栏,每头牛有不同喜好,有的想去,有的不想,对于给定的喜好表,你需要求出最大可以满足多少头牛的需求. 2.给你学生数和课程数,以及学生上的 ...

随机推荐

  1. PHPExcel 使用心得

    最近有个项目需要将数据导出成excel,以前都没接触过.便google一下知道了PHPExcel 这个据说很强大的类库. 写这个博文主要目的等同于做笔记 1首先看了下官方的文档.http://phpe ...

  2. linux更换阿里云的源的shell脚本

    #!/bin/bash##########################################Function: update source#Usage: bash update_sour ...

  3. Django day16 Auth组件

    一:Auth组件 -django内置的用户认证系统,可以快速的实现,登录,注销,修改密码... -怎么用? (1)先创建超级用户: -python3 manage.py createsuperuser ...

  4. 【Codeforces】Codeforces Round #373 (Div. 2) -C

    C. Efim and Strange Grade Efim just received his grade for the last test. He studies in a special sc ...

  5. IIS 7.0、IIS 7.5 和 IIS 8.0 使用的 HTTP 状态代码【转载自微软官方】

    HTTP 状态代码 本部分描述 IIS 7.0.IIS 7.5 和 IIS 8.0 使用的 HTTP 状态代码. 注意 本文不会列出 HTTP 规范中所述的每个可能的 HTTP 状态代码.本文只包括 ...

  6. Spring logger 配置

    1. logback-spring.xml <?xml version="1.0" encoding="UTF-8"?> <configura ...

  7. Linux rsync配置用于服务器之间传输大量的数据

    Linux的rsync 配置,用于服务器之间远程传大量的数据   [教程主题]:rsync [课程录制]: 创E [主要内容] [1] rsync介绍 Rsync(Remote Synchronize ...

  8. C#调用FFMPEG实现桌面录制(视频+音频+生成本地文件)

    不得不说FFMPEG真是个神奇的玩意,所接触的部分不过万一.网上有个很火的例子是c++方面的,当然这个功能还是用c++来实现比较妥当. 然而我不会c++ 因为我的功能需求比较简单,只要实现基本的录制就 ...

  9. css3基础篇三

    CSS3 文本阴影 在 CSS3 中,text-shadow 可向文本应用阴影. 您能够规定水平阴影.垂直阴影.模糊距离,以及阴影的颜色: 实例 向标题添加阴影: h1 { text-shadow: ...

  10. Maven常见异常及解决方法

    异常1: [ERROR] Failed to execute goal on project biz_zhuhai: Could not resolve dependencies for projec ...