题目描述
In the Game Red Alert, a group of soviet infantry marches towards our base. And we have N Prism Tanks to defend our base. Suppose the coming infantry marches in a ROW*COLUMN rectangle grid, and keeps the shape unchanged. A Prism Tank can eliminate infantry in any row or column at a shot. Prism Tank is weak in self-defense, so your task is to assign the least Prism Tanks, fire simultaneously to eliminate all the invading enemies. If our Prism Tank is enough, submit any assignment using the least Prism Tanks. Otherwise, report it.
输入
First line: 3 integers ROW,COLUMN,N--number of Prism Tanks we have now(ROW<=1000, COLUMN<=1000,N<=1000). Line 2 to ROW+1: Each line is a binary 01 string with length COLUMN, represent the shape of infantry. Set 1 if a position have a soldier, otherwise 0.
输出
If there exist an assignment, output it in the format: k1+k2 ROW: R1 R2...Rk1 COLUMN: C1 C2...Ck2 k1+k2 is the totoal number of Prism Tanks. Otherwise print one line "NOT ENOUGH TANK".
样例输入
4 4 4 0101 1010 1010 0010
样例输出
3 ROW: 1 COLUMN: 1 3
看了这个题目后,知道二分图性质的都知道这个题就是二分图的最小点集覆盖,把每行看成一条边,每列看成一条边,若str[i][j]==‘1’,表明i和j有一条边,这样就得到了一个二分图的模型,求最小的二分图最小点集覆盖就可以了,可是最小点集覆盖好求,但是要确定选哪些点呢!这个就需要好好考虑一下了,
想一想,对于一条边i-j,若不选i就是选j,是吧?做完最大匹配后,我们查没一条边,若link[j]==-1,表明j没有选,那么我们就选i,选完row后,再来看列的,对于一条边i-j,若i选了,就不选j,若i没有选,就选j,这样这道题目就解决了,代码特别丑,就不贴出来了,若有过路者想看的话,可以留言,谢谢
作者 chensunrise
hust 1027 Enemy Target!,布布扣,bubuko.com
原文地址:http://www.cnblogs.com/chensunrise/p/3773704.html