【无聊放个模板系列】POJ 1274 (匈牙利)
- #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 (匈牙利)的更多相关文章
- 【无聊放个模板系列】POJ 3678 2-SAT
#include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #inc ...
- 【无聊放个模板系列】BZOJ 3172 (AC自动机)
#include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #inc ...
- 【无聊放个模板系列】POJ2752 EXKMP
#include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #inc ...
- 【无聊放个模板系列】HDU 3506 (四边形不等式优化DP-经典石子合并问题[环形])
#include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #inc ...
- 【无聊放个模板系列】BZOJ 1597 斜率优化
STL 双向队列DEQUE版本 #include<cstdio> #include<cstdlib> #include<cstring> #include<i ...
- 【无聊放个模板系列】HDU 1269 (SCC)
#include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #inc ...
- 【无聊放个模板系列】HDU 1358 KMP
#include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #inc ...
- 【无聊放个模板系列】HDU 3068 MANACHER
#include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #inc ...
- 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 农夫约翰上个 ...
随机推荐
- 安全接口 interface --显示实现接口
前言:当我们定义接口的成员的时候不需要写访问控制符,因为它是默认public的,也只能是public.当一个类要实现这个接口的时候,自然要公开其成员.一直以来我都这么做. interface Inte ...
- 1.6建造者模式(生成器模式) Builder
1.概念:将一个复杂对象的构建和他的表示分离,使得同样的构件可以创建不同的表示. 2.实例:肯德基和中餐,肯德基抽象了整个做菜的复杂过程(相同的构建),然后在不同的店铺进行实现(不同的表示).中餐往往 ...
- 在慕课学习Bootstrap
---恢复内容开始--- 可以用class=“h1”等给元素加h1样式 <h>------<small>----</small></h> < ...
- opencv 手写选择题阅卷 (三)训练分类器
opencv 手写选择题阅卷 (三)训练分类器 1,分类器选择:SVM 本来一开始用的KNN分类器,但这个分类器目前没有实现保存训练数据的功能,所以选择了SVN分类器; 2,样本图像的预处理和特征提取 ...
- python pil 安装
Ubuntu下 sudo pip install pil 安装PIL可能会出现问题,例如安装完成时显示JPEG support not available 或者 ZLIB (PNG/ZIP) supp ...
- 关于apache Alias斜杠/的实验
1.Alias /icons/ "D:/wamp/bin/apache/Apache2.2.17/icons/" 访问http://localhost/icons/正常,访问htt ...
- Java.lang.RuntimeException: Unable to instantiate activity ComponentInfo
如果你更新了ADT的新版本,而工程文件中使用了其他的jar包,也可能会出现"java.lang.RuntimeException: Unable to instantiate activit ...
- Python串行运算、并行运算、多线程、多进程对比实验
转自:http://www.redicecn.com/html/Python/20111223/355.html Python发挥不了多核处理器的性能(据说是受限于GIL,被锁住只能用一个CPU核心, ...
- Demo学习: Dialogs Anonymous Callback
Dialogs\Dialogs Anonymous Callback 窗体回调函数使用. 1. 标准回调函数 ShowMessage(const Msg: string; CallBack: TUni ...
- Oracle SQL的硬解析、软解析、软软解析
Oracle中每条sql在执行前都要解析,解析分为硬解析.软解析.软软解析. Oracle会缓存DML语句,相同的DML语句会进行软解析.但不会缓存DDL语句,所以DDL每次都做硬解析.硬解析是一个很 ...