Bessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 <= N <= 500). The grid contains K asteroids (1 <= K <= 10,000), which are conveniently located at the lattice points of the grid.
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.
Line 1: Two integers N and K, separated by a single space.
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.
3 4 1 1 1 3 2 2 3 2
2
POJ:https://vjudge.net/problem/POJ-3041 UESTC:https://vjudge.net/problem/UESTC-253
二分图匹配
Bessie 驾驶着他的太空飞船呆呆2号在太空旅行,途径一段危险地带,他希望自己能安全通过这段区域,于是他将这片区域的地图扫描进入了太空飞船,地图是一个N x N的网络 (1 <= N <= 500),其中有K颗小行星 (1 <= K <= 10,000)。
还好Bessie有一个强力的武器能够一发光束将一整行或者一整列的小行星轰成灰烬。 这种光束的价格高昂,材料稀有,所以他希望更少的使用这个光束。现在把地图给你,你能帮Bessie计算一下,摧毁掉这些小行星至少需要几发光束。
对于这道题目,我们把每一个点(x,y)的横纵坐标分开。对于所有的横坐标我们设一个集合X,而对于纵坐标用一个集合Y。若有障碍物(x,y),我们在X中的x连一条边到Y中的y。这样原来的所有障碍点就成了图中的一条边。
最小点覆盖的意思是,求出最少的点的集合使得每一条边都至少有一个端点在集合中。在二分图中,最小点覆盖=最大匹配数
至于什么是最大匹配呢,就是求一个最大的边集使得没有任意两个边有同样的端点。
更多关于二分图的相关问题可以看一看这一篇文章:http://blog.csdn.net/tham_/article/details/72872199
转载于:https://www.cnblogs.com/SYCstudio/p/7138206.html