题目大意:$N*N$的网格中有$n$颗行星,若每次可以消去一整行或一整列,求最小的攻击次数使得消去所有行星. 解题关键:将光束当做顶点,行星当做连接光束的边建图,题目转化为求该图的最小顶点覆盖,图的最小顶点覆盖是$NP$问题,又因为该图是二分图(水平方向的点和竖直方向的点),而二分图的最大匹配=最小顶点覆盖,即可求解该问题. #include<cstdio> #include<cstring> #include<algorithm> #include<cstdli…
/** 题目:poj3041 Asteroids 链接:http://poj.org/problem?id=3041 题意:给定n*n的矩阵,'X'表示障碍物,'.'表示空格;你有一把枪,每一发子弹可以消除一行或者一列的障碍物, 问最少需要多少颗子弹可以清空障碍物? 思路:最小点集覆盖问题,等价于最大匹配.把所有的行看做二分图的左边的节点,所有的列看做二分图右边的节点. 如果f[i][j]==true;那么第i行与第j列有关系,连一条边.对这个二分图求最大匹配即可. 采用匈牙利算法. 匈牙利算法…
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…
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 <…
原文链接http://www.cnblogs.com/zhouzhendong/p/8229200.html 题目传送门 - POJ3041 题意概括 有一个n*n的矩阵,有些点是障碍物. 现在每次可以炸掉某一行或者某一列的障碍物,问最少炸几次. 题解 对于点(x,y),我们建立一条x<->y+n的边,然后发现这是一个二分图. 我们只需要求最小点覆盖就可以了,因为最小点覆盖=最大匹配,所以匈牙利一波即可. 代码 #include <cstring> #include <cst…
题目链接. 分析: 暂略. AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <queue> #include <algorithm> #include <cmath> #include <string> #include <map> using namespace s…
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…
Machine Schedule Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6701    Accepted Submission(s): 3358 Problem Description As we all know, machine scheduling is a very classical problem in comput…
The King’s Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3471    Accepted Submission(s): 1231 Problem Description In the Kingdom of Silence, the king has a new problem. There are N cit…
Strategic Game Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8503    Accepted Submission(s): 4093 Problem Description Bob enjoys playing computer games, especially strategic games, but somet…