HDU 1179:Ollivanders: Makers of Fine Wands since 382 BC.
模板二分图:
#include<bits/stdc++.h>
using namespace std;
const int maxn = 110;
int n, m, f[maxn], ans, k, x;
bool mat[maxn][maxn];
int mac[maxn];
bool v[maxn];
int dfs(int x) {
for (int i = 1; i <= n; ++i)
if (mat[x][i] && !v[i]) {
v[i] = 1;
if (!mac[i] || dfs(mac[i])) {
mac[i] = x;
return 1;
}
}
return 0;
}
int main() {
//freopen("in.txt", "r", stdin);
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
while (cin >> n && n) {
memset(mac, 0, sizeof mac);
memset(mat, 0, sizeof mat);
cin >> m;
for (int i = 1; i <= m; ++i) {
cin >> k;
while (k--)
cin >> x, mat[i][x] = 1;
}
ans = 0;
for (int i = 1; i <= m; ++i) {
memset(v, false, sizeof v);
if (dfs(i))ans++;
}
cout << ans << endl;
}
}
HDU 1179:Ollivanders: Makers of Fine Wands since 382 BC.的更多相关文章
- HDU——1179 Ollivanders: Makers of Fine Wands since 382 BC.
Ollivanders: Makers of Fine Wands since 382 BC. Time Limit: 2000/1000 MS (Java/Others) Memory Lim ...
- hdu-----(1179)Ollivanders: Makers of Fine Wands since 382 BC.(二分匹配)
Ollivanders: Makers of Fine Wands since 382 BC. Time Limit: 2000/1000 MS (Java/Others) Memory Lim ...
- Ollivanders: Makers of Fine Wands since 382 BC.
Ollivanders: Makers of Fine Wands since 382 BC. Time L ...
- hdu-1179 Ollivanders: Makers of Fine Wands since 382 BC.---二分图匹配模板
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1179 题目大意: 有n个人要去买魔杖,有m根魔杖(和哈利波特去买魔杖的时候一样,是由魔杖选人).接下 ...
- HDU - 6409:没有兄弟的舞会(数学+思维)
链接:HDU - 6409:没有兄弟的舞会 题意: 题解: 求出最大的 l[i] 的最大值 L 和 r[i] 的最大值 R,那么 h 一定在 [L, R] 中.枚举每一个最大值,那么每一个区间的对于答 ...
- POJ 3321:Apple Tree + HDU 3887:Counting Offspring(DFS序+树状数组)
http://poj.org/problem?id=3321 http://acm.hdu.edu.cn/showproblem.php?pid=3887 POJ 3321: 题意:给出一棵根节点为1 ...
- 【九度OJ】题目1179:阶乘 解题报告
[九度OJ]题目1179:阶乘 解题报告 标签(空格分隔): 九度OJ http://ac.jobdu.com/problem.php?pid=1179 题目描述: 输入n, 求y1=1!+3!+-m ...
- HDU 2732:Leapin' Lizards(最大流)
http://acm.hdu.edu.cn/showproblem.php?pid=2732 题意:给出两个地图,蜥蜴从一个柱子跳跃到另外一个地方,那么这个柱子就可能会坍塌,第一个地图是柱子可以容忍跳 ...
- HDU 4289:Control(最小割)
http://acm.hdu.edu.cn/showproblem.php?pid=4289 题意:有n个城市,m条无向边,小偷要从s点开始逃到d点,在每个城市安放监控的花费是sa[i],问最小花费可 ...
- HDU 3605:Escape(最大流+状态压缩)
http://acm.hdu.edu.cn/showproblem.php?pid=3605 题意:有n个人要去到m个星球上,这n个人每个人对m个星球有一个选择,即愿不愿意去,"Y" ...
随机推荐
- cookie和session的区别?一文讲透
一.问题 cookie和session的区别? 二.回答 1.总结如下- cookie: - cookie存储于客户端本地,即浏览器缓存 - cookie存储着sessionId,作为后台sessio ...
- 在TCP四次挥手中,为什么客户端发送FIN后,还可以发送报文
在TCP四次挥手中,为什么客户端发送FIN后,还可以发送报文 首先回顾下四次挥手的过程. 第一次挥手:客户端停止发送数据,主动关闭 TCP 连接,处于FIN_WAIT1状态,等待服务端确认. 第二次挥 ...
- The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission,iphone手机video标签报错
The request is not allowed by the user agent or the platform in the current context, possibly becaus ...
- windows端口被占用怎么办?
简单只需要按照一下命令查找到对应的端口kill掉就好了 1.查看本机所有的端口信息 netstat -ano 2.查看本机指定端口信息 netstat -ano | findstr "端口号 ...
- 轻量型 Web SCADA 组态软件 TopLink
图扑物联 发布了一款工业物联网边缘侧应用场景的轻量型 Web SCADA 组态软件 Iotopo TopLink.该产品采用 B/S 架构,提供 Web 管理界面,软件包大小仅 23MB,无需安装客户 ...
- 安装华企盾DSC防泄密软件:编辑文件不加密常见问题,运维工程师必看
1.先查看客户端日志主进程是否是加密进程.日志中是不是勾选智能半透明.加密类型是否有添加 2.用procmon监控保存的文件找出writefile的进程是否有添加,进程树是否有父进程,加密类型是否正确 ...
- Hash-based Message Authentication Code(HMAC)
一.引言 在现代信息安全领域,消息认证码(Message Authentication Code,简称MAC)起着至关重要的作用.Hash-based Message Authentication C ...
- CentOS7部署后优化配置
1.安装必要的组件.升级 yum -y install wget vim cd /etc/yum.repos.d/ rm -rf /etc/yum.repos.d/*.repo wget http:/ ...
- 技本功|Hive优化之监控(三)
Hive是大数据领域常用的组件之一,主要是大数据离线数仓的运算,关于Hive的性能调优在日常工作和面试中是经常涉及的一个点,因此掌握一些Hive调优是必不可少的技能.影响Hive效率的主要有数据倾斜. ...
- 斯坦福 UE4 C++ ActionRoguelike游戏实例教程 10.控制台变量的用法 & 静态函数库 & 使用对象通道对碰撞进行控制
斯坦福课程 UE4 C++ ActionRoguelike游戏实例教程 0.绪论 概述 本文对应Lecture 15, 61 - Console Variables for debugging and ...