zoukankan      html  css  js  c++  java
  • hust 1027 Enemy Target!

    题目描述

    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
    至少做到我努力了
  • 相关阅读:
    linux下activemq安装与配置
    Linux设置开放一个端口
    使用codis-admin搭建codis集群
    elasticsearch7.0安装及配置优化
    ELK详细安装部署
    filebeat安装部署
    ElasticSearch-5.3.1集群环境搭建,安装ElasticSearch-head插件,安装错误解决
    手把手教你搭建一个 Elasticsearch 集群
    ES 集群管理(集群规划、集群搭建、集群管理)
    Elasticsearch如何关掉服务
  • 原文地址:https://www.cnblogs.com/chensunrise/p/3773704.html
Copyright © 2011-2022 走看看