博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj 3689 The Windy's (KM)
阅读量:5287 次
发布时间:2019-06-14

本文共 3122 字,大约阅读时间需要 10 分钟。

The Windy's
Time Limit: 5000MS   Memory Limit: 65536K
Total Submissions: 2846   Accepted: 1232

Description

The Windy's is a world famous toy factory that owns M top-class workshop to make toys. This year the manager receives N orders for toys. The manager knows that every order will take different amount of hours in different workshops. More precisely, the i-th order will take Zij hours if the toys are making in the j-th workshop. Moreover, each order's work must be wholly completed in the same workshop. And a workshop can not switch to another order until it has finished the previous one. The switch does not cost any time.

The manager wants to minimize the average of the finishing time of the N orders. Can you help him?

Input

The first line of input is the number of test case. The first line of each test case contains two integers, N and M (1 ≤ N,M ≤ 50).

The next N lines each contain M integers, describing the matrix Zij (1 ≤ Zij ≤ 100,000) There is a blank line before each test case.

Output

For each test case output the answer on a single line. The result should be rounded to six decimal places.

Sample Input

33 4100 100 100 199 99 99 198 98 98 13 41 100 100 10099 1 99 9998 98 1 983 41 100 100 1001 99 99 9998 1 98 98

Sample Output

2.0000001.0000001.333333 这题的构图还是很精妙的 注意要学会拆点
#include
using namespace std;const int INF = INT_MAX;const int xmax = 55;const int ymax = 2510;int n, m;int input[xmax][xmax];int map[xmax][ymax];int sx[xmax], sy[ymax], lx[xmax], ly[ymax];int match[ymax];int dfs(int a){ sx[a]=1; for(int i=1;i<=m;i++) { if(sy[i]==0 && lx[a]+ly[i]==map[a][i]) { sy[i]=1; if(match[i]==-1 || dfs(match[i])==1) { match[i]=a; return 1; } } } return 0;}int km(){ for(int i=1;i<=n;i++) { lx[i]=INF; for(int j=1;j<=m;j++) { if(map[i][j]>lx[i]) { lx[i]=map[i][j]; } } } memset(match, -1, sizeof(match)); memset(ly, 0, sizeof(ly)); for(int k=1;k<=n;k++) { while(1) { memset(sx, 0, sizeof(sx)); memset(sy, 0, sizeof(sy)); if(dfs(k)) break; int dmin = INF; for(int i=1; i<=n;i++) { if(sx[i]) { for(int j=1;j<=m;j++) { if(!sy[j]) { dmin=(map[i][j]-lx[i]-ly[j])
>cases; while(cases--) { scanf("%d%d",&n,&m); memset(input, 0, sizeof(input)); memset(map, 0, sizeof(map)); for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { scanf("%d",&input[i][j]); } } for(int s=1;s<=n;s++) for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) map[s][(i-1)*m+j] = i*input[s][j]; m=n*m; printf("%.6f\n",km()*1.0/n); } return 0;}

 

转载于:https://www.cnblogs.com/w0w0/archive/2012/06/11/2545607.html

你可能感兴趣的文章
C# Stream 和 byte[] 之间的转换
查看>>
OMG: daily scrum nine
查看>>
redis与spring结合错误情况
查看>>
第六章 字节码执行方式--解释执行和JIT
查看>>
字符串方法title()、istitle()
查看>>
yield语句
查看>>
查看linux系统中占用cpu最高的语句
查看>>
[洛谷P1738]洛谷的文件夹
查看>>
ubuntu server设置时区和更新时间
查看>>
【京东咚咚架构演进】-- 好文收藏
查看>>
【HTML】网页中如何让DIV在网页滚动到特定位置时出现
查看>>
文件序列化
查看>>
Bootstrap--响应式导航条布局
查看>>
Learning Python 009 dict(字典)和 set
查看>>
JavaScript中随着鼠标拖拽而移动的块
查看>>
HDU 1021 一道水题
查看>>
The operation couldn’t be completed. (LaunchServicesError error 0.)
查看>>
php每天一题:strlen()与mb_strlen()的作用分别是什么
查看>>
工作中收集JSCRIPT代码之(下拉框篇)
查看>>
《转载》POI导出excel日期格式
查看>>