CSU1631
来源:互联网 发布:东北软件学院地址 编辑:程序博客网 时间:2024/05/02 00:24
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1631
Facility Locations
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 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 20 21 12 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;}
- CSU1631
- CSU1631: Facility Locations
- cdoj1091
- 得到ImageView的图片,压缩成PNG,并得到二进制流数据
- 第十一周项目0-是春哥啊
- Codeforces #200(div.2) 模拟练习赛
- 大才非学不成,大志非学不就——周旭龙
- CSU1631
- iPhone Launch之启动类型的判断
- 关于C#接口的使用
- OC基础概述
- 算法杂货铺——分类算法之朴素贝叶斯分类(Naive Bayesian classification)
- 第十二周 项目四(5):点和圆的关系
- CSU1636
- Redis-基础-1
- CKEditor3.6.4配置及在网站中的使用(一)