1070: [SCOI2007]修车 - BZOJ
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的更多相关文章
- BZOJ 1070: [SCOI2007]修车 [最小费用最大流]
1070: [SCOI2007]修车 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 4936 Solved: 2032[Submit][Status] ...
- 【BZOJ】1070: [SCOI2007]修车
1070: [SCOI2007]修车 Description 同 一时刻有N位车主带着他们的爱车来到了汽车维修中心.维修中心共有M位技术人员,不同的技术人员对不同的车进行维修所用的时间是不同的.现在需 ...
- bzoj 1070: [SCOI2007]修车 费用流
1070: [SCOI2007]修车 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 2785 Solved: 1110[Submit][Status] ...
- bzoj 1070 [SCOI2007]修车(最小费用最大流)
1070: [SCOI2007]修车 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 3515 Solved: 1411[Submit][Status] ...
- 1070: [SCOI2007]修车
1070: [SCOI2007]修车 https://www.lydsy.com/JudgeOnline/problem.php?id=1070 分析: 每个第几次修车等的时间都不一样,当前第i个人修 ...
- [BZOJ 1070] [SCOI2007] 修车 【费用流】
题目链接:BZOJ - 1070 题目分析 首先想到拆点,把每个技术人员拆成 n 个点,从某个技术人员拆出的第 i 个点,向某辆车连边,表示这是这个技术人员修的倒数第 i 辆车.那么这一次修车对整个答 ...
- 【BZOJ】1070: [SCOI2007]修车(费用流+特殊的技巧)
http://www.lydsy.com/JudgeOnline/problem.php?id=1070 好神的题!!!orz 首先我是sb不会拆点..... 首先,每一个技术人员维修车辆都有一个先后 ...
- BZOJ 1070: [SCOI2007]修车(费用流)
http://www.lydsy.com/JudgeOnline/problem.php?id=1070 题意: 思路: 神奇的构图. 因为排在后面的人需要等待前面的车修好,这里将每个技术人员拆成n个 ...
- bzoj 1070 [SCOI2007]修车——网络流(拆边)
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1070 后面还有几辆车在这个人这儿修,自己这辆车的时间对总时间的贡献就要多乘上几倍. 所以可以 ...
随机推荐
- 每天一道LeetCode--374. Guess Number Higher or Lower
We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to gues ...
- activity传递数据
这些都是老生常谈了,到处都搜的到,但是因为经常忘记,放着好调用: 传递数据: Intent intent = new Intent(); Bundle bundle = new Bundle(); b ...
- php 提交保存成功页面 倒计时 跳转
前几天做了一个简单的成功提示页面! 有需要的可以拿去用,写的不好 欢迎指正!~~ 因为工程是在CI下面做的,url 自己用的话需要改正下函数!site_url() 这个函数式CI框架的 <ht ...
- FMS服务器在centos下安装
首先当然得先下载安装包了 http://pan.baidu.com/s/1jGL1Nvw #要先安装一下这个包,否则会提收提示错误,缺少libcap yum install compat-libcap ...
- 位图文件格式及linux下C语言来操作位图文件
说到图片,位图(Bitmap)当然是最简单的,它是Windows显示图片的基本格式,其文件扩展名为*.BMP.由于没有经过任何的压缩,故BMP图片往往很大.在Windows下,任何格式的图片文件都要转 ...
- 直播开始:'云榨汁机'诞生记--聊聊JavaScript中的'业务建模'
闭包是JavaScript中的一个重要特性,在之前的博文中,我们说闭包是一个'看似简单,其实很有内涵'的特性.当我们用JavaScript来实现相对复杂的业务建模时,我们可以如何利用'闭包'这个特性呢 ...
- Ajax 技术一
一.Ajax概述 1.历史起源 1998年,微软公司Outlook Web Access研发小组在当时的IE浏览器中集成了一种技术,可以在客户端无刷新的前提下向服务器端发送Http请求,这门技术称之为 ...
- idea基本
IntelliJ IDEA特色功能 IDEA所提倡的是智能编码,是减少程序员的工作,IDEA的特色功能有以下25点:智能的选取在很多时候我们要选取某个方法,或某个循环或想一步一步从一个变量到整个类慢慢 ...
- Qt学习总结-ui篇
控件设置透明度: QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect(this); effect->setOpacity(0. ...
- Mac 如何恢复出厂设置
首先将电脑关机然后按电源键启动启动的时候电脑会出现白色什么都没有的界面这时按住 option(alt)键会出现磁盘选择界面然后选择一个叫 Reocorvry10.X.X的硬盘点击那个硬盘按照上面的指示 ...