【最小点覆盖】POJ3041-Asteroids】的更多相关文章

Description 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…
传送门 题意: 给一个N*N的矩阵,有些格子有障碍,要求我们消除这些障碍,问每次消除一行或一列的障碍,最少要几次.   解析: 把每一行与每一列当做二分图两边的点. 某格子有障碍,则对应行与列连边. 选出最少的点,使得所有边被覆盖. 最小点覆盖. ——代码 #include <cstdio> #include <cstring> #define M(x, a) memset(a, x, sizeof(a)) using namespace std; ; int n, k, cnt,…
   Asteroids POJ - 3041 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 po…
http://poj.org/problem?id=3041 Asteroids Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 17543   Accepted: 9548 Description Bessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 <= N <…
Asteroids Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 16242 Accepted: 8833 Description 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 astero…
/** 题目:poj3041 Asteroids 链接:http://poj.org/problem?id=3041 题意:给定n*n的矩阵,'X'表示障碍物,'.'表示空格;你有一把枪,每一发子弹可以消除一行或者一列的障碍物, 问最少需要多少颗子弹可以清空障碍物? 思路:最小点集覆盖问题,等价于最大匹配.把所有的行看做二分图的左边的节点,所有的列看做二分图右边的节点. 如果f[i][j]==true;那么第i行与第j列有关系,连一条边.对这个二分图求最大匹配即可. 采用匈牙利算法. 匈牙利算法…
Asteroids Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 24789   Accepted: 13439 Description 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 a…
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. Fortun…
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. Fortun…
每次选择清除一行或者一列上的小行星.最少选择几次. 将行和列抽象成点,第i行为节点i+n,第j列为节点j,每个行星则是一条边,连接了所在的行列. 于是问题转化成最小点覆盖.二分图的最小点覆盖==最大匹配. #include <cstdio> #include <cstring> const int N=505<<1; int n,vis[N],link[N],g[N][N]; int find(int u) { for(int i=1; i<=n*2; i++)…