POJ 3041 Asteroids (最小点覆盖集)
题意
给出一个N*N的矩阵,有些格子上有障碍,要求每次消除一行或者一列的障碍,最少消除多少次可以全部清除障碍。
思路
把关键点取出来:一个障碍至少需要被它的行或者列中的一个消除。
也许是最近在做二分图匹配专辑吧……很容易想到这就是最小点覆盖集:每条边都至少需要一个点被选中,称这条边被覆盖。
而由König定理可知二分图最小点覆盖 = 最大匹配。所以解法也就出来了:把行当作左点集,列当作右点集,对于每一个障碍,把它的行和列对应的点连一条边,此二分图的最大匹配就是答案了。
代码
using namespace std;
const int MAXV = 1005; //N1+N2
vector adj[MAXV];
struct MaximumMatchingOfBipartiteGraph{
int vn;
void init(int n){ //二分图两点集点的个数
vn = n;
for (int i = 0; iPOJ 3041 Asteroids (最小点覆盖集)的更多相关文章
- Asteroids POJ - 3041 【最小点覆盖集】
Bessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N g ...
- poj 3041 Asteroids(最小点覆盖)
http://poj.org/problem?id=3041 Asteroids Time Limit: 1000MS Memory Limit: 65536K Total Submissions ...
- poj 3041 Asteroids 最小点覆盖/最大匹配
Asteroids Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 16242 Accepted: 8833 Descriptio ...
- [poj] 3041 Asteroids || 最小点覆盖=最大二分图匹配
原题 本题为最小点覆盖,而最小点覆盖=最大二分图匹配 //最小点覆盖:用最少的点(左右两边集合的点)让每条边都至少和其中一个点关联. #include<cstdio> #include&l ...
- POJ 3041 Asteroids 最小点覆盖 == 二分图的最大匹配
Description Bessie wants to navigate her spaceship through a dangerous asteroid field in the shape o ...
- Asteroids POJ - 3041 二分图最小点覆盖
Asteroids POJ - 3041 Bessie wants to navigate her spaceship through a dangerous asteroid field in ...
- POJ 3041(最小点覆盖)
题意: 假如你如今正处在一个N*N的矩阵中,这个矩阵里面有K个障碍物,你拥有一把武器,一发弹药一次能消灭一行或一列的障碍物,求最小的弹药消灭所有障碍物 输入为: N K 接下来有K行,每行包括 ...
- PKU 3041 Asteroids 最小点覆盖(最大匹配模板题)
题目大意:给你一个N*N的矩阵, 里面有K个星球, 我们可以让武器攻击矩阵的一行或者一列来使得这个星球被击碎, 现在问你最少需要几个这种武器才能把所有的星球击碎? 解题思路:关键是建模构图 把每一行当 ...
- Strategic game POJ - 1463 【最小点覆盖集】
Bob enjoys playing computer games, especially strategic games, but sometimes he cannot find the solu ...
随机推荐
- c++ 枚举 在函数中的应用
#include <iostream> using namespace std; enum RespErrNo { SUCCESS = , INVALID_URL = , INVALID_ ...
- Educational Codeforces Round 11 C. Hard Process 前缀和+二分
题目链接: http://codeforces.com/contest/660/problem/C 题意: 将最多k个0变成1,使得连续的1的个数最大 题解: 二分连续的1的个数x.用前缀和判断区间[ ...
- 关于ios中的文本操作-简介
来源:About Text Handling in iOS 官方文档 iOS平台为我们提供了许多在app中展示文本和让用户编辑文本的方式.同时,它也允许你在app视图中展示格式化的文本和网页内容.你可 ...
- <%@page include%>、<%@include%>、<jsp:include>三者之间的本质区别
<%@page include%>.<%@include%>.<jsp:include>三者之间的本质区别 先从它的几个内置对象说起. application和se ...
- IOS:利用dispatch_once创建单例
在之前有一篇学习笔记中,记载了一篇如何在OC中实现单例的文章:<IOS学习笔记4—Objective C—创建单例>自苹果引入了Grand Central Dispatch (GCD)(M ...
- **bootstrap常见常用样式总结
1.水平居中 用 .text-center 类
- 原版win7镜像IE主页被篡改?
装了几次系统,镜像是从“MSDN我告诉你”上下载的,但是每次装完,发现IE主页不是microsoft的官方网页,而是www.3456.com. 这就奇了怪了,难道“MSDN我告诉你”提供的不是原版镜像 ...
- lintcode:三数之和
题目 三数之和 给出一个有n个整数的数组S,在S中找到三个整数a, b, c,找到所有使得a + b + c = 0的三元组. 样例 如S = {-1 0 1 2 -1 -4}, 你需要返回的三元组集 ...
- 87. Scramble String
题目: Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty subs ...
- 39. Combination Sum
题目: Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C ...