CSU1631: Facility Locations

Description

The HDWBP Inc. has n clients and needs to service these clients by opening k facilities. Each opened facility can serve any number of clients and each client must be served by an open facility. There are m potential locations for these k facilities. The
cost of serving client j at potential location i is a non-negative integer cij . These costs satisfy a locality property: for two clients j and j’ and two facilities i and i’, we have cij ≤ ci’j + ci’j’ + cij’ . Given the costs, the CEO of HDWBP Inc. ultimately
wants to know the cheapest way to open k facilities and assign clients to these open facilities. For now, he needs your help to determine if it is possible to do this task without any cost (i.e. with cost zero).

Input

The input consists of a single test case. The first line contains three integers m, n, k where 1 ≤ m ≤ 100, 1 ≤ n ≤ 100 and 1 ≤ k ≤ m. Each of the next m lines contains n non-negative integers where the jth integer in the ith line is cij ≤ 10000.

Output

Display yes if it is possible to do the task with cost zero; otherwise, display no.

Sample Input

3 2 2
0 2
1 1
2 0

Sample Output

yes

HINT

Source

题意:从n行m列的矩阵中选出至多k行,使得每一列都有0

思路:暴力

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <climits>
using namespace std;

#define LS 2*i
#define RS 2*i+1
#define UP(i,x,y) for(i=x;i<=y;i++)
#define DOWN(i,x,y) for(i=x;i>=y;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define W(a) while(a)
#define gcd(a,b) __gcd(a,b)
#define LL long long
#define N 25
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EXP 1e-8

int n,m,k;
int vis[105];

int main()
{
    int i,j,k,x;
    W(~scanf("%d%d%d",&n,&m,&k))
    {
        int mm = 0,kk = 0;
        MEM(vis,0);
        UP(i,1,n)
        {
            int flag = 0;
            UP(j,1,m)
            {
                scanf("%d",&x);
                if(x || vis[j]) continue;
                if(!flag) kk++;
                flag = 1;
                vis[j] = 1;
                mm++;
            }
        }
        if(mm == m&&kk<=k)
            puts("yes");
        else
            puts("no");
    }
    return 0;
}
时间: 2024-10-31 02:21:16

CSU1631: Facility Locations的相关文章

湖南多校对抗5.24

据说A,B,C题都比较水这里就不放代码了 D:Facility Locations 然而D题是一个脑经急转弯的题:有m行,n列,每个位置有可能为0,也可能不为0,问最多选K行是不是可以使得每一列都至少有一个0,其中代价c有个约束条件:These costs satisfy a locality property: for two clients j and j’ and two facilities i and i’, we have cij ≤ ci’j + ci’j’ + cij’ . 一看

Tomcat Server Locations

Server Locations 表示服务器位置 use workspace metadata表示使用工作空间 use Tomcat installation表示使用tomcat安装 use custom location表示使用自定义位置

SourceTree不出现用户登录窗口,提示错误fatal: unable to access&#39;...&#39;; error setting certificate verify locations

SourceTree不出现用户登录窗口,提示错误fatal: unable to access'...'; error setting certificate verify locations; ...\Git\mingw64\libexec\ssl\certs 去查看这个这个目录下的文件是否存在,不存在则放到对应的地方即可. SourceTree不出现用户登录窗口,提示错误fatal: unable to access'...'; error setting certificate verif

异常:Message 850 not found; No message file for product=network, facility=NL解决方案

一.异常信息: Message 850 not found; No message file for product=network, facility=NL  二.解决方案: 后来在网上查了一下,是找不到oracle安装主目录的原因.想了一想可能是环境变量出问题了,export了一下发现果然没有$ORACLE_HOME 那几个环境变量,看了一下?.bash_profile没有发现问题,于是source .bash_profile了一下,正常启动了oracle 想了一阵子之后明白了问题所在:用s

A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No Java virtual machine was found after searching the following locations: /usr/local/eclipse/

linux系统下jdk是已经安装好的情况之下软件出现 A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No Java virtual machine was found after searching the following locations: /usr/local/eclipse/jre/bin/java java in yo

Method, apparatus and system for acquiring a global promotion facility utilizing a data-less transaction

A data processing system includes a global promotion facility and a plurality of processors coupled by an interconnect. In response to execution of an acquisition instruction by a first processor among the plurality of processors, the first processor

Ubuntu Eclipse启动时报错:A Java RunTime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No java virtual machine was found after searching the following locations:

此问题起于我在Ubuntu1004上装了两个版本的eclipse:Galieo+helios:卸载前者后出现启动不了eclipse的问题:在网上找了下,可以按如下过程进行解决: Eclipse 3.6 在 Ubuntu 10.04 下会出现一个很奇怪的现象,我没有经过测试,无法确定是Ubuntu 10.04 还是 JDK 还是 Eclipse本身造成的. 这个现象是: 可以在终端顺利启动Eclipse,但是鼠标双击,或者用起动器启动就会出现如下的内容: A Java RunTime Enviro

hbase.client.RetriesExhaustedException: Can&#39;t get the locations hive关联Hbase查询报错

特征1: hbase.client.RetriesExhaustedException: Can't get the locations 特征2: hbase日志报错如下:org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase/hbaseid 特征3: unexpected error, closing socket connection a

将Eclipse中的Web项目部署到Tomcat与修改Tomcat服务器Server Locations

1.将Eclipse中的Web项目部署到Tomcat 记得开始学习JavaWeb的时候,首先用的是Eclipse开发,但是有一个问题始终没有弄明白,做好的Web项目是如何发布到Tomcat服务器上的呢?最后得到了一个结论,那就是Eclipse这个软件可能是将项目发布到了一个临时的目录,只有打开Eclipse的时候,启动服务器才能运行Web项目.也正是因为这个原因,一直用的都是MyEclipse开发Java Web项目(十分的方便和顺手).这几天用的比较多,因此又对这个问题产生了兴趣,能不能将做好