poj3041——最小点覆盖】的更多相关文章

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…
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…
[pixiv] https://www.pixiv.net/member_illust.php?mode=medium&illust_id=54859604 向大(hei)佬(e)势力学(di)习(tou) 二分图其实早就学了,可是无赖自己当初没好好听讲,变种就不说了,连匈牙利算法都不会.这次给了我一个好好复习改过自新的机会,既把匈牙利搞熟了,也算是理解了一些变种. 最小路径覆盖: 题意 用最少的出租车送完所有的乘客 将时间上可以接上的乘客连边 在一个图中,希望用最少的路径将所有点走遍,为什么…
传送门 题意: 给一个N*N的矩阵,有些格子有障碍,要求我们消除这些障碍,问每次消除一行或一列的障碍,最少要几次.   解析: 把每一行与每一列当做二分图两边的点. 某格子有障碍,则对应行与列连边. 选出最少的点,使得所有边被覆盖. 最小点覆盖. ——代码 #include <cstdio> #include <cstring> #define M(x, a) memset(a, x, sizeof(a)) using namespace std; ; int n, k, cnt,…
给一个矩阵,里面有一些不同颜色的气球.每次能够消灭一行或一列中某一种颜色的气球,问你在k次及以内,有哪些颜色的气球是不管怎样也消不完的. 那么思路就是,对每一种颜色的气球求最小点覆盖.>k 则为答案. 相当于 poj3041的加强版,由于矩阵中不是每个点都是等价的. #include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algorithm>…
题目链接:Asteroids - POJ 3041 - Virtual Judge  https://vjudge.net/problem/POJ-3041 第一行输入一个n和一个m表示在n*n的网格里有m个小行星,接下来m行都会有一个小行星的坐标(x,y),现在有一种武器可以一次性把一行或一列上的小行星消灭掉,现在问我们最少要多少次攻击才能消灭所有的小行星. 第一次做二分图最小点覆盖的题目,思路是我们把每一行每一列都抽象成一个点,总共n*n个,行和列的点组成两个点集,那么小行星的坐标(x,y)…
   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…
//匈牙利算法-DFS //求最小点覆盖集 == 求最大匹配 //Time:0Ms Memory:208K #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> using namespace std; #define MAX 105 #define INF 0x3f3f3f3f int n,m,k; int gp[MAX][MAX]; bool sx[MAX],s…
每次选择清除一行或者一列上的小行星.最少选择几次. 将行和列抽象成点,第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++)…
Muddy Fields Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8881   Accepted: 3300 Description Rain has pummeled the cows' field, a rectangular grid of R rows and C columns (1 <= R <= 50, 1 <= C <= 50). While good for the grass, t…