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 ...
随机推荐
- Android学习——数据存储之文件存储
将数据存储到文件中并读取数据 1.新建FilePersistenceTest项目,并修改activity_main.xml中的代码,如下:(只加入了EditText,用于输入文本内容,不管输入什么按下 ...
- Android开发笔记(13)——ListFragment
转载请注明:http://www.cnblogs.com/igoslly/p/6959108.html ListFragment ListFragment是继承于Fragment的类,专门用于包含Li ...
- RunLoop相关知识
RunLoop,翻译过来是运行环路.我们在创建命令行项目和创建ios项目时,发现命令行项目当最后一行代码执行完后项目就自动退出了,而ios项目确可以一直运行,知道用户手动点击退出按钮.这就是因为ios ...
- OpenWRT 常用软件安装
root@Jack:/tmp/opkg-lists# opkg--help opkg:unrecognized option `--help' opkgmust have one sub-comman ...
- JSP_内置对象_out
out对象是JspWriter类的实例,是向客户端输出内容的常用对象,常用方法如下: void println() 向客户端打印字符串 void clear() 清除缓冲区的内容,如果在flush之后 ...
- APICloud上啦加载下拉刷新模块
apicloud有自带的上啦加载下拉刷新,当让也可以用第三方或者在模块库里面找一个使用 一.下拉刷新,一下代码写在 apiready = function (){} 里面 apiready = fun ...
- appium+python,app自动化测试框架
目前正在写一个app的自动化UI测试框架,目录结构如, 脚本还在调试,实现的方法是从excel表格读取测试用例,执行完成后会将结果保存到Excel中. 等待.......
- 定位IO瓶颈的方法,iowait低,IO就没有到瓶颈?
通过分析mpstat的iowait和iostat的util%,判断IO瓶颈 IO瓶颈往往是我们可能会忽略的地方(我们常会看top.free.netstat等等,但经常会忽略IO的负载情况),今天给大家 ...
- Linux 中,基础命令 command not found...问题
linux中出现基本命令找不到的问题,经过查找发现是/etc/profile文件出现了问题,解决方案如下: 问题详细: [root@master ~]# ll bash: ls: command no ...
- 亚马逊免费服务器搭建Discuz!论坛过程(二)
1: 登录服务器 在实例页面,点击连接连接,按照如下步骤,即可登录服务器. 登录成功之后,如下所示.你就可以随意玩耍了. 2: 系统优化 证书登录当然安全,但是不太方便并且麻烦,本人还是习惯用户名密 ...