#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<stack>
using namespace std;
#define Maxn 210 int match[Maxn];
int n,m; struct node
{
int x,y,next;
}t[Maxn*Maxn];int len;
int first[Maxn]; void ins(int x,int y)
{
t[++len].x=x;t[len].y=y;
t[len].next=first[x];first[x]=len;
} bool chw[Maxn]; bool dfs(int x)
{
for(int i=first[x];i;i=t[i].next)
{
int y=t[i].y;
if(chw[y]) continue;
chw[y]=;
if(!match[y]||dfs(match[y]))
{
match[y]=x;
return ;
}
}
return ;
} void ffind()
{
int ans=;
memset(match,,sizeof(match));
for(int i=;i<=n;i++)
{
memset(chw,,sizeof(chw));
if(dfs(i)) ans++;
}
printf("%d\n",ans);
} int main()
{
while(scanf("%d%d",&n,&m)!=EOF)
{
len=;
memset(first,,sizeof(first));
for(int i=;i<=n;i++)
{
int x;
scanf("%d",&x);
while(x--)
{
int y;
scanf("%d",&y);
ins(i,y);
}
}
ffind();
}
return ;
}

2016-11-17 21:13:53

匈牙利

【无聊放个模板系列】POJ 1274 (匈牙利)的更多相关文章

  1. 【无聊放个模板系列】POJ 3678 2-SAT

    #include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #inc ...

  2. 【无聊放个模板系列】BZOJ 3172 (AC自动机)

    #include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #inc ...

  3. 【无聊放个模板系列】POJ2752 EXKMP

    #include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #inc ...

  4. 【无聊放个模板系列】HDU 3506 (四边形不等式优化DP-经典石子合并问题[环形])

    #include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #inc ...

  5. 【无聊放个模板系列】BZOJ 1597 斜率优化

    STL 双向队列DEQUE版本 #include<cstdio> #include<cstdlib> #include<cstring> #include<i ...

  6. 【无聊放个模板系列】HDU 1269 (SCC)

    #include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #inc ...

  7. 【无聊放个模板系列】HDU 1358 KMP

    #include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #inc ...

  8. 【无聊放个模板系列】HDU 3068 MANACHER

    #include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #inc ...

  9. 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 农夫约翰上个 ...

随机推荐

  1. WebResponse 取出全国省市区的邮编

    WebResponse用法(根据省市区地址查询其邮编): class Program { static string url { get; set; } static void Main(string ...

  2. sql语句聚合等疑难问题收集

    ------------------------------------------------------------------------------------ 除法运算 select 500 ...

  3. Android Animation学习笔记

    原文地址: http://www.cnblogs.com/feisky/archive/2010/01/11/1644482.html 关于动画的实现,Android提供了Animation,在And ...

  4. (POJ 3694) Network 求桥个数

    题目链接:http://poj.org/problem?id=3694Description A network administrator manages a large network. The ...

  5. What are Upgrade, Product and Package Codes used for? By pusu

    Following content is reprinted from here, please go to the original website for more information. Au ...

  6. 隐藏内容_网络推广_seo中级视频教程详解

    课程背景:SEO(Search Engine Optimization),汉译为搜索引擎优化.搜索引擎优化是一种利用搜索引擎的搜索规则来提高目的网站在有关搜索引擎内的排名的方式.SEO目的理解是:为网 ...

  7. 教您如何使用MySQL group_concat函数

    MySQL group_concat函数是典型的字符串连接函数,下面就为您介绍MySQL group_concat的语法,希望对您学习MySQL group_concat函数有所帮助. MySQL g ...

  8. automake使用

    antuomake 流程图: http://blog.csdn.net/houwei544/article/details/8185916 这个教程不错 https://www.ibm.com/dev ...

  9. ecshop中无限处理分类

    数据库表记录结构 <?php $sql = "SELECT c.cat_id, c.cat_name, c.measure_unit, c.parent_id, c.is_show, ...

  10. sql server 查看创建视图的sql语句

    --sp_helptext v_viewnamesp_helptext port_dept--效果