CSU1631

题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1631


Facility Locations

Time Limit: 1 Sec   Memory Limit: 128 MB
Submit: 48   Solved: 13
[ Submit][ Status][ Web Board]

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

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;

int s[105][105],vis[105];

int main()
{
    int k,n,m;
    while(~scanf("%d%d%d",&m,&n,&k))
    {
        memset(vis,0,sizeof(vis));
        int cnt=0;
        for(int i=0; i<m; i++)
            for(int j=0; j<n; j++)
                scanf("%d",&s[i][j]);
        int flag;
        int ff=0;
        for(int i=0; i<m; i++)
        {
            flag=0;
            for(int j=0; j<n; j++)
            {
                if(s[i][j]==0&&(!vis[j]))
                {
                    flag=1;
                    cnt++;
                    vis[j]=1;
                }
            }
            if(flag)
            {
                ff++;
                flag=0;
            }
        }
        if(cnt>=n&&ff<=k)
        printf ("yes\n");
        else
            printf ("no\n");
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值