Description

同一时刻有N位车主带着他们的爱车来到了汽车维修中心。维修中心共有M位技术人员,不同的技术人员对不同的车进行维修所用的时间是不同的。现在需要安排这M位技术人员所维修的车及顺序,使得顾客平均等待的时间最小。 说明:顾客的等待时间是指从他把车送至维修中心到维修完毕所用的时间。
Input

第一行有两个m,n,表示技术人员数与顾客数。 接下来n行,每行m个整数。第i+1行第j个数表示第j位技术人员维修第i辆车需要用的时间T。
Output

最小平均等待时间,答案精确到小数点后2位。
Sample Input
2 2
3 2
1 4
Sample Output
1.50

HINT

数据范围: (2<=M<=9,1<=N<=60), (1<=T<=1000)

费用流建图,把m个人每个人拆成n个点,表示的是第m个人倒数第i个修这个车,那么费用就是i*时间

没想到zkw费用流模板打错了

在dfs过程里

我是这么写的

 function dfs(x,flow:longint):longint;
var
i,d,min:longint;
begin
flag[x]:=time;
if x=t then
begin
inc(ans,flow*dis[t]);
exit(flow);
end;
i:=first[x];
dfs:=;
while i<> do
begin
d:=dis[x]+w[i]-dis[last[i]];
min:=flow;
if min>liu[i] then min:=liu[i];
if (liu[i]>) and (d<f[last[i]]) then f[last[i]]:=d;
if (d=) and (flag[last[i]]<>time) and (min>) then
begin
d:=dfs(last[i],min);
dec(flow,d);
inc(dfs,d);
inc(liu[i xor ],d);
dec(liu[i],d);
end;
if flow= then break;
i:=next[i];
end;
end;

但是应该这么写

 function dfs(x,flow:longint):longint;
var
i,d,min:longint;
begin
if x=t then
begin
inc(ans,flow*dis[t]);
exit(flow);
end;
i:=first[x];
flag[x]:=time;
dfs:=;
while i<> do
begin
d:=dis[x]+w[i]-dis[last[i]];
min:=flow;
if min>liu[i] then min:=liu[i];
if (liu[i]>) and (d<f[last[i]]) then f[last[i]]:=d;
if (d=) and (flag[last[i]]<>time) and (min>) then
begin
d:=dfs(last[i],min);
dec(flow,d);
inc(dfs,d);
inc(liu[i xor ],d);
dec(liu[i],d);
end;
if flow= then break;
i:=next[i];
end;
end;

应该先判断是否走到了汇点,再做标记,如果不这样的话,就无法多路增广了,即只能到达汇点一次,然后他会立即增加dis,这个时候dis就是错的了(因为较小的那个dis还没有增广完全)

对于其他的点,都是增广到不能再增广,所以没有问题,只要访问一次就行了(应该是这样的吧)

写了几遍了,连这个都没有发现,唉~~~~

 const
maxn=;
maxm=;
inf=;
var
n,m,tot,s,t,ans,time:longint;
first,f,dis,flag:array[..maxn*maxm]of longint;
last,next,w,liu:array[..maxn*maxn*maxm*maxm]of longint; procedure insert(x,y,f,ww:longint);
begin
inc(tot);
last[tot]:=y;
next[tot]:=first[x];
first[x]:=tot;
w[tot]:=ww;
liu[tot]:=f;
end; procedure init;
var
i,j,k,x:longint;
begin
read(m,n);
tot:=;
s:=;
t:=n*m+n+;
for i:= to n do
for j:= to m do
begin
read(x);
for k:= to n do
begin
insert((j-)*n+k,n*m+i,,x*k);
insert(n*m+i,(j-)*n+k,,-x*k);
end;
end;
for i:= to n*m do
begin
insert(s,i,,);
insert(i,s,,);
end;
for i:= to n do
begin
insert(n*m+i,t,,);
insert(t,n*m+i,,);
end;
end; function dfs(x,flow:longint):longint;
var
i,d,min:longint;
begin
if x=t then
begin
inc(ans,flow*dis[t]);
exit(flow);
end;
i:=first[x];
flag[x]:=time;
dfs:=;
while i<> do
begin
d:=dis[x]+w[i]-dis[last[i]];
min:=flow;
if min>liu[i] then min:=liu[i];
if (liu[i]>) and (d<f[last[i]]) then f[last[i]]:=d;
if (d=) and (flag[last[i]]<>time) and (min>) then
begin
d:=dfs(last[i],min);
dec(flow,d);
inc(dfs,d);
inc(liu[i xor ],d);
dec(liu[i],d);
end;
if flow= then break;
i:=next[i];
end;
end; procedure work;
var
del,i:longint;
begin
while true do
begin
for i:=s to t do
f[i]:=inf;
inc(time);
dfs(s,inf);
del:=inf;
for i:=s to t do
if (flag[i]<>time) and (f[i]<del) then del:=f[i];
if del=inf then break;
for i:=s to t do
if flag[i]<>time then inc(dis[i],del);
end;
writeln(ans/n::);
end; begin
init;
work;
end.

1070: [SCOI2007]修车 - BZOJ的更多相关文章

  1. BZOJ 1070: [SCOI2007]修车 [最小费用最大流]

    1070: [SCOI2007]修车 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 4936  Solved: 2032[Submit][Status] ...

  2. 【BZOJ】1070: [SCOI2007]修车

    1070: [SCOI2007]修车 Description 同 一时刻有N位车主带着他们的爱车来到了汽车维修中心.维修中心共有M位技术人员,不同的技术人员对不同的车进行维修所用的时间是不同的.现在需 ...

  3. bzoj 1070: [SCOI2007]修车 费用流

    1070: [SCOI2007]修车 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 2785  Solved: 1110[Submit][Status] ...

  4. bzoj 1070 [SCOI2007]修车(最小费用最大流)

    1070: [SCOI2007]修车 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 3515  Solved: 1411[Submit][Status] ...

  5. 1070: [SCOI2007]修车

    1070: [SCOI2007]修车 https://www.lydsy.com/JudgeOnline/problem.php?id=1070 分析: 每个第几次修车等的时间都不一样,当前第i个人修 ...

  6. [BZOJ 1070] [SCOI2007] 修车 【费用流】

    题目链接:BZOJ - 1070 题目分析 首先想到拆点,把每个技术人员拆成 n 个点,从某个技术人员拆出的第 i 个点,向某辆车连边,表示这是这个技术人员修的倒数第 i 辆车.那么这一次修车对整个答 ...

  7. 【BZOJ】1070: [SCOI2007]修车(费用流+特殊的技巧)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1070 好神的题!!!orz 首先我是sb不会拆点..... 首先,每一个技术人员维修车辆都有一个先后 ...

  8. BZOJ 1070: [SCOI2007]修车(费用流)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1070 题意: 思路: 神奇的构图. 因为排在后面的人需要等待前面的车修好,这里将每个技术人员拆成n个 ...

  9. bzoj 1070 [SCOI2007]修车——网络流(拆边)

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1070 后面还有几辆车在这个人这儿修,自己这辆车的时间对总时间的贡献就要多乘上几倍. 所以可以 ...

随机推荐

  1. Activity之间传递数据或数据包Bundle,传递对象,对象序列化,对象实现Parcelable接口

    package com.gaojinhua.android.activitymsg; import android.content.Intent; import android.os.Bundle; ...

  2. Android之画廊点击内容显示

    package com.example.Gallery; import com.example.Gallery.R; import android.os.Bundle; import android. ...

  3. 微软SQLHelper.cs类 中文版

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Co ...

  4. ajax后台return,js判断方法

    private string CreateJoson(string result, string message) { return "{" + "\"resu ...

  5. 20150309--gridview

    GridView: 使用代码套用模板,变为DataList的样式,添加<asp:TemplateField>标签,(注意必须加上<Columns>) <asp:GridV ...

  6. 20141128—JavaScript对象

    JavaScript 中的所有事物都是对象:字符串.数值.数组.函数... String 对象的 length 属性来获得字符串的长度: var message="Hello World!& ...

  7. jquery的延迟加载插件Lazy Load Plugin for jQuery

    下载:https://github.com/tuupola/jquery_lazyload 使用:http://www.appelsiini.net/projects/lazyload 翻译:http ...

  8. 8个WEB前端创意HTML5动画应用精选

    和十几年前相比,现在的网页加入了很多动画元素,从之前的Flash到现在的HTML5,动画样式越来越丰富,动画制作也越来越便捷.本文精选了几款非常富有创意的HTML5动画应用,欣赏一下吧. 1.HTML ...

  9. java springmvc Log4j filter等(稍微完善一下项目)

    仅供参考-接上文 springmvc  1.设置Log4jConfigListener日志监听(可以为开发调试.发布后运行的意外调试.等) 在src/main/resources目录下新建log4j. ...

  10. ie8中使用placeholder

    placeholder 是 html5 中的新属性,考虑到还有不少 ie8 的用户,所以找了一个 ie8 的 placeholder 的补丁,如下: <script type="tex ...