Asteroids Time Limit: 1000MS   Memory Limit: 65536K       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), wh…
这道题实现起来还是比较简单的,但是理解起来可能有点困难. 我最开始想到的是贪心法,每次消灭当前小行星最多的一行或一列.然而WA了.Discuss区里已经有高人给出反例. 下面给出正确的解法 我们把行和列抽象成点,把小行星抽象成边,每出现一个小行星,就把其行列所对应的点连起来.这样就形成了一个无向图$G=\left(V, E\right)$.问题就转化为了求这个图G中的最小点覆盖,即求一个元素数量尽可能小的点集$V' \subset V$,$E$中的所有边均与其内的一点相连. 最小点覆盖问题是一个…
以行列为点建图,每个点(x,y) 对应一条边连接x,y.二分图的最小点覆盖=最大匹配 //#pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #include<iostream> #include<sstream>…
POJ 3041 Asteroids / UESTC 253 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), whic…
题目:POJ 3041 Asteroids http://poj.org/problem?id=3041 分析: 把位置下标看出一条边,这显然是一个二分图最小顶点覆盖的问题,Hungary就好. 挑战: 输出一组可行解.构造,已知二分图的两个点集U和V,s-U-V-t,在最大匹配的残留网络里,选从s出发能到达的V中的点 沿途可以到达的U集中的点的路径就都被覆盖了,然后在选择U集合中无法到达的点.对于二分图中任意一条边,其中必有一点属于U集合, 所以前面选出的点集S是一个覆盖.并且S中V和U对应的…
poj       3041——Asteroids Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22604   Accepted: 12247 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 g…
题目传送门 /* 题意:每次能消灭一行或一列的障碍物,要求最少的次数. 匈牙利算法:把行和列看做两个集合,当有障碍物连接时连一条边,问题转换为最小点覆盖数==二分图最大匹配数 趣味入门:http://blog.csdn.net/dark_scope/article/details/8880547 */ #include <cstdio> #include <algorithm> #include <cstring> #include <vector> usi…
原题连接:http://poj.org/problem?id=3041 Asteroids Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 17985   Accepted: 9798 Description Bessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 <…
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 <…
http://poj.org/problem?id=3041 Asteroids Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12601   Accepted: 6849 Description Bessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 <= N <…