【无聊放个模板系列】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 农夫约翰上个 ...
随机推荐
- 第五篇、Uber用视频播放做启动动画
import UIKit import AVFoundation class GuidePage: FxBasePage { @IBOutlet var backImageView:UIImageVi ...
- FastSocket学习笔记~制定自已的传输协议
对于TCP或者UDP来说,它们作于传输层的协议,有着自己的标准,或者叫格式,在我们看TCP格式之前先了解一下计算机的基础知识,字节,它是计算机世界的一个小单位,也是我们可以理会到的,如一个utf-8英 ...
- (转)使用Amoeba 实现MySQL DB 读写分离
Amoeba(变形虫)项目是一个开源框架,于2008年开始发布一款 Amoeba for Mysql软件: 这个软件致力于MySQL的分布式数据库前端代理层,它主要在应用层访问MySQL的时候充当SQ ...
- Git的安装以及一些操作
1.安装Git-2.5.1-64-bit.exe 一直下一步直至完成 2.注册github账号 官网地址:https://github.com/github 3.找到一个按钮“New Reposit ...
- C++与Lua交互(一)
引言 之前做手游项目时,客户端用lua做脚本,基本所有游戏逻辑都用它完成,玩起来有点不爽,感觉"太重"了.而我又比较偏服务端这边(仅有C++),所以热情不高.最近,加入了一个端游项 ...
- 解决Scala异常处理java.lang.OutOfMemoryError: Java heap space error
需求:百万.千万.4千万级日志对设备进行除重环境:设备内存64G,scala单机版运行shell文件日志:20G 48000000.log4.0G 10000000.log396M 1000000.l ...
- 【C#高级编程(学习与理解)】1.1 C#与.NET的关系
1.C#语言不能孤立使用,而必须和.NET Framework一起考虑.C#编译器专门用于.NET,这表示用C#编写的所有代码总是在.NET Framework中运行. 2.C#就其本身而言只是一种语 ...
- STM32F10XXX 启动设置
在STMF103XXX 里,可以通过Boot[1:0]引脚选择3种不同的启动模式: 启动模式选择引脚 启动模式 说明 BOOT1 BOOT ...
- 【原】Oracle拼接字段
select FLIGHT_DATE, replace(wm_concat(FLIGHT_NO), ',', '*') FLIGHT_NO from T2001 group by FLIGHT_DAT ...
- 菜鸟聊:PHP
学习PHP已经有2个月时间了,从一开始的一片空白,到现在的刚刚入门,我对PHP的了解也有更多的认知,希望通过我对PHP的理解,能帮助到更多像我一样的新手更早的认识PHP.(PS:以下内容的一部分是摘自 ...