POJ 3041 Asteroids
最小点覆盖数==最大匹配数
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 12678 | Accepted: 6904 |
Description
Fortunately, Bessie has a powerful weapon that can vaporize all the asteroids in any given row or column of the grid with a single shot.This weapon is quite expensive, so she wishes to use it sparingly.Given the location of all the asteroids in the field, find the minimum number of shots Bessie needs to fire to eliminate all of the asteroids.
Input
* Lines 2..K+1: Each line contains two space-separated integers R and C (1 <= R, C <= N) denoting the row and column coordinates of an asteroid, respectively.
Output
Sample Input
3 4
1 1
1 3
2 2
3 2
Sample Output
2
Hint
The following diagram represents the data, where "X" is an asteroid and "." is empty space:
X.X
.X.
.X.
OUTPUT DETAILS:
Bessie may fire across row 1 to destroy the asteroids at (1,1) and (1,3), and then she may fire down column 2 to destroy the asteroids at (2,2) and (3,2).
Source
#include <iostream>
#include <cstdio> #include <cstring> #include <vector> using namespace std; int N,P,from[1000]; bool match(int u) int hungary() int main() |
* This source code was highlighted by YcdoiT. ( style: Vs )
POJ 3041 Asteroids的更多相关文章
- POJ 3041 Asteroids / UESTC 253 Asteroids(二分图最大匹配,最小点匹配)
POJ 3041 Asteroids / UESTC 253 Asteroids(二分图最大匹配,最小点匹配) Description Bessie wants to navigate her spa ...
- POJ 3041 Asteroids (对偶性,二分图匹配)
题目:POJ 3041 Asteroids http://poj.org/problem?id=3041 分析: 把位置下标看出一条边,这显然是一个二分图最小顶点覆盖的问题,Hungary就好. 挑战 ...
- poj 3041——Asteroids
poj 3041——Asteroids Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22604 Accep ...
- 二分图最大匹配(匈牙利算法) POJ 3041 Asteroids
题目传送门 /* 题意:每次能消灭一行或一列的障碍物,要求最少的次数. 匈牙利算法:把行和列看做两个集合,当有障碍物连接时连一条边,问题转换为最小点覆盖数==二分图最大匹配数 趣味入门:http:// ...
- poj 3041 Asteroids(最小点覆盖)
http://poj.org/problem?id=3041 Asteroids Time Limit: 1000MS Memory Limit: 65536K Total Submissions ...
- poj 3041 Asteroids (最大匹配最小顶点覆盖——匈牙利模板题)
http://poj.org/problem?id=3041 Asteroids Time Limit: 1000MS Memory Limit: 65536K Total Submissions ...
- POJ 3041 Asteroids 二分图
原题连接:http://poj.org/problem?id=3041 Asteroids Time Limit: 1000MS Memory Limit: 65536K Total Submis ...
- POJ 3041 Asteroids(模板——二分最大匹配(BFS增广))
题目链接: http://poj.org/problem?id=3041 Description Bessie wants to navigate her spaceship through a da ...
- POJ 3041.Asteroids 最小顶点覆盖
Asteroids Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22905 Accepted: 12421 Descr ...
- POJ 3041 Asteroids 匈牙利算法,最大流解法,行列为点 难度:1
http://poj.org/problem?id=3041 #include <cstdio> #include <cstring> #include <vector& ...
随机推荐
- 利用Gulp优化部署Web项目[长文慎入]
Gulp Gulp是一款项目自动化的构建工具,与Grunt一样可以通过创建任务(Task)来帮助我们自动完成一些工作流的内容.当然,今天我们的内容并不是讨论这二者的区别,仅仅是介绍介绍如何利用Gulp ...
- Opencv step by step - 绘图
有时候我们需要在图像上写一些字或者画一些简单的几何图案. 祭上代码: #include <cv.h> #include <highgui.h> int main(int arg ...
- JavaScript split() 方法
split() 方法用于把一个字符串分割成字符串数组.
- 关于页面滚动值scrollTop在FireFox与Chrome浏览器间的兼容问题
需求 最近在做博客的目录功能,发现一个在现代浏览器间的一个bug,或是称之为差异,即页面滚动值(scrollTop)的获取与设定. 在此之前先说一下关于页面元素的坐标获取,这张图的经典性不必再提. 实 ...
- IT行业工作6年回顾
IT行业工作6年回顾 时间一晃,已经出来工作六七年了,当真岁月如梭,时光如箭,回首往昔,当真叹一句:“太多东西都失于路上”,今天偷得浮生半日闲,做个回顾,权当是给自己做个小结,也希望给他人一些可用的借 ...
- 汇顶科技&&硬件类笔试题目
汇顶科技硬件类笔试题目,每年都有变化,但是题目类型都差不多.汇顶科技17年在南京地区大概招了20个左右吧,给的待遇还是不错的,工作地点上海深圳
- SimpleDateFormat出错
今天写了一个SB代码,就是字符串“2014-04-03”转换为java.sql.Date.因为java.sql.Date extends java.util.Date.所以一般的思路是先将String ...
- use case
- Html巩固
1.html元素都支持全局属性(通用的属性)和事件属性. a标签:定义一个超文本链接,链接到另一个超文本文件的! button:定义一个点击按钮,按钮是出发当前页面的事件.
- Excel如何查找名字重复的数据
来源于:http://jingyan.baidu.com/article/414eccf6091ff86b431f0aec.html Cokery今天在帮助同事整理数据的时候遇到了一个难题,就是在Ex ...