hdoj--2119--Matrix(最小点覆盖)
Matrix
Your task is to give out the minimum times of deleting all the '1' in the matrix.
The first line contains two integers n,m(1<=n,m<=100), n is the number of rows of the given matrix and m is the number of columns of the given matrix.
The next n lines describe the matrix:each line contains m integer, which may be either ‘1’ or ‘0’.
n=0 indicate the end of input.
3 3
0 0 0
1 0 1
0 1 0
0
2
#include<stdio.h>
#include<vector>
#include<string.h>
#include<algorithm>
using namespace std;
vector<int>map[200];
int pipei[200],used[200];
int find(int x)
{
for(int i=0;i<map[x].size();i++)
{
int y=map[x][i];
if(!used[y])
{
used[y]=1;
if(!pipei[y]||find(pipei[y]))
{
pipei[y]=x;
return 1;
}
}
}
return 0;
}
int main()
{
int n,m;
while(scanf("%d",&n),n)
{
scanf("%d",&m);
for(int i=1;i<=n;i++)
{
map[i].clear();
pipei[i]=0;
}
int a;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
scanf("%d",&a);
if(a)
map[i].push_back(j);
}
}
int sum=0;
for(int i=1;i<=n;i++)
{
memset(used,0,sizeof(used));
sum+=find(i);
}
printf("%d\n",sum);
}
}
hdoj--2119--Matrix(最小点覆盖)的更多相关文章
- hdu 2119 Matrix(二分匹配)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2119 Matrix Time Limit: 5000/1000 MS (Java/Others) ...
- HDU 1498 50 years, 50 colors(最小点覆盖,坑称号)
50 years, 50 colors Problem Description On Octorber 21st, HDU 50-year-celebration, 50-color balloons ...
- hdu 2236(二分图最小点覆盖+二分)
无题II Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- hdu 1498(最小点覆盖集)
50 years, 50 colors Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- ACM/ICPC 之 机器调度-匈牙利算法解最小点覆盖集(DFS)(POJ1325)
//匈牙利算法-DFS //求最小点覆盖集 == 求最大匹配 //Time:0Ms Memory:208K #include<iostream> #include<cstring&g ...
- 【POJ 3041】Asteroids (最小点覆盖)
每次选择清除一行或者一列上的小行星.最少选择几次. 将行和列抽象成点,第i行为节点i+n,第j列为节点j,每个行星则是一条边,连接了所在的行列. 于是问题转化成最小点覆盖.二分图的最小点覆盖==最大匹 ...
- POJ 2226 最小点覆盖(经典建图)
Muddy Fields Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8881 Accepted: 3300 Desc ...
- nyoj 237 游戏高手的烦恼 二分匹配--最小点覆盖
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=237 二分匹配--最小点覆盖模板题 Tips:用邻接矩阵超时,用数组模拟邻接表WA,暂时只 ...
- [USACO2005][POJ2226]Muddy Fields(二分图最小点覆盖)
题目:http://poj.org/problem?id=2226 题意:给你一个字符矩阵,每个位置只能有"*"或者“.",连续的横着或者竖的“*"可以用一块木 ...
- POJ3041Asteroids(最小点覆盖+有点小抽象)
Asteroids Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 18289 Accepted: 9968 Descri ...
随机推荐
- 5.29MyBatis Generator
二.MyBatis Generator CRUD(创建,检索,更新,删除) 与表结构匹配的Java POJO BLOB (binary large object),二进制大对象,是一个可以存储二进制文 ...
- buf.readInt8函数详解
offset {Number} 0 noAssert {Boolean} 默认:false 返回:{Number} 从该 Buffer 指定的 offset 位置开始读取一个有符号的8位整数值. 设置 ...
- VMWare虚拟机移动
1. 背景: 虚拟机:VM3 原安装路径:C:\Users\Administrator\Documents\Virtual Machines 移动到目标路径:D:\Virtual Machines ...
- Eclipse代码自动提示(内容辅助content assist)
Eclipse中默认是输入"."后出现自动提示,用于类成员的自动提示,可是有时候我们希望它能在我们输入类的首字母后就出现自动提示,可以节省大量的输入时间(虽然按alt + /会出现 ...
- SmartUpload实现文件上传
(一)SmartUpload组件简介 SmartUpload组件 专门用于实现文件上传及下载的免费组件 (二)SmartUpload组件特点 使用简单:编写少量代码,完成上传下载功能 能够控制上传 ...
- JavaScript的基本语法(一)
一.常用的表单元素有: 文本框(text). 密码框(password). 多行文本框(<textarea>) 单选按钮(radio). 复选框(checkbox). 列表框(<se ...
- Windows下使用Caffe-Resnet
参考文章: 编译历程参考:CNN:Windows下编译使用Caffe和Caffe2 caffe的VS版本源代码直接保留了sample里面的shell命令,当然这些shell命令在Windows平台下是 ...
- ubuntu 16.04 安装QT问题
使用 sudo sh ./**.run 有错误: 增加 文件的可运行权限: sudo chmod +x Qt.run 直接运行: ./Qt.run 可完成安装
- java中的位运算及移位运算
为了方便对二进制位进行操作,Java给我们提供了以下四个二进制位操作符: & 按位与 | 按位或 ^ 按位异或 ~ 按位取反 Java中有三个移位运算符: 左移:&l ...
- NSURLProtectionSpace 证书认证的上下文
个NSURLProtectionSpace提供如下信息: //401的认证方式的realm字段的值 (NSString*)realm; //401的认证方式,指定是否密码发送安全. -(BOOL)re ...