当前位置: 首页 > 编程日记 > 正文

bzoj1070————2016——3——14

传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1070;

题目概括:

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)

Source

看到这个大概就应该知道是费用流了吧,可是怎么处理一个人等其他人的时间呢? 显然拆点撒,拆T组点,每个人向第j的机器的第z个修的点连一条边,权植为z*time[i][j](为什么是这个呢?

因为你在修的时候别人和你都在等待),所以这道题就这样写完了,但感觉点有点多,所以就写了个(zkw费用流)但是是抄模板的。。。。。醉(好歹有点理解也是好的);

普通费用流也可以过,只不过要小心点.........

 1 #include<iostream>
 2 #include<cstring>
 3 #include<cstdio>
 4 #define inf 0x7fffffff
 5 #define maxn 500000
 6 int n,m,tot,s,t,ans;
 7 int pre[maxn],v[maxn],cap[maxn],dis[maxn],sla[maxn],now[maxn],cost[maxn];
 8 int a[100][100];
 9 bool vis[maxn];
10 using namespace std;
11 int num(int i,int j)
12 {
13     return (i*n+j);
14 }
15 void ins(int a,int b, int c, int d)
16 {
17     tot++; pre[tot]=now[a]; now[a]=tot; v[tot]=b; cap[tot]=c; cost[tot]=d;
18 }
19 void insert(int a, int b, int c, int d)
20 {
21     ins(a,b,c,d); ins (b,a,0,-d);
22 }
23 int kk(int x, int f)
24 {
25     int left=f;
26     if (x==t) {ans+=f*dis[s]; return f;
27     }
28     vis[x]=1;
29     for (int i=now[x]; i; i=pre[i])
30     {
31         if (cap[i]>0 && !vis[v[i]])
32         {
33             if (dis[v[i]]+cost[i]-dis[x]==0)
34             {
35                 int delt=kk(v[i],min(cap[i],left));
36                 if (delt>0) cap[i]-=delt,cap[i^1]+=delt,left-=delt;
37                 if (left==0) return f;
38                 
39             }
40             else
41             sla[v[i]]=min(sla[v[i]],dis[v[i]]+cost[i]-dis[x]);
42         }
43     }
44     return (f-left);
45 }
46 bool dfs()
47 {
48     int delt=inf;
49     for (int i=s; i<=t; i++)
50     if (!vis[i]) delt=min(delt,sla[i]),sla[i]=inf;
51     if (delt==inf ) return  true;
52     for (int i=s; i<=t; i++)
53     if (vis[i]) dis[i]+=delt;
54     return false;
55 }
56 void zkw()
57 {
58     for (int i=s; i<=t; i++) dis[i]=0,sla[i]=inf;
59     do{
60         do {memset(vis,0,sizeof(vis));
61         } while(kk(s,inf));
62         
63     }while (!dfs());
64 }
65 int main()
66 {
67     scanf("%d%d",&m,&n);
68     for (int i=1; i <=n; i++) for (int j=1; j<=m; j++) scanf("%d",&a[i][j]);
69     tot=1;
70     s=0; t=n*m+n+1;
71     for (int i=1; i<=n; i++) insert(s,i,1,0);
72     for (int i=1; i<=n; i++)
73         for (int j=1; j<=m; j++)
74             for (int z=1; z<=n; z++)
75             {
76                 insert(i,num(j,z),1,z*a[i][j]);
77             }
78     for (int i=1; i<=m; i++)
79         for (int j=1; j<=n; j++)
80         insert(num(i,j),t,1,0);
81     zkw();
82     printf("%.2lf\n",(1.0*ans)/(1.0*n));     
83 }
View Code

转载于:https://www.cnblogs.com/HQHQ/p/5276906.html

相关文章:

CSS兼容性汇总

http://www.jb51.net/css/469020.html CSS属性Hack 把属性hack分为 前缀属性hack和 后缀属性hack CSS属性Hack&#xff08;前缀&#xff09;针对的浏览器_color:red;IE6及其以下的版本*color:red ;或者 color:red;IE7及其以下的版本CSS属性Hack&#xff08;后缀&#xff09;针对…

Vue 过渡组件,可实现组件或者页面的动画过渡或者css过渡

使用过渡效果&#xff0c;可以优化用户体验&#xff0c;Vue给我们封装了一个很好用的组件&#xff0c;专门用来处理过渡效果&#xff0c;下面我们来看看怎么使用它&#xff1b; Vue 提供了 transition 的封装组件&#xff0c;在下列情形中&#xff0c;可以给任何元素和组件添加…

解释型和编译型编程语言_解释型和编译型编程语言:有什么区别?

解释型和编译型编程语言Every program is a set of instructions, whether it’s to add two numbers or send a request over the internet. Compilers and interpreters take human-readable code and convert it to computer-readable machine code. 每个程序都是一组指令&a…

Beta 冲刺 (1/7)

队名&#xff1a;天机组 组员1友林 228&#xff08;组长&#xff09; 今日完成&#xff1a;查找了相关资料及api文档。明天计划&#xff1a;继续相关资料及源码。剩余任务&#xff1a;优化网络通讯机制主要困难&#xff1a;查找的代码调试较为困难。收获及疑问&#xff1a;暂无…

Vue全局路由侦听beforeEach路由守卫附代码使用示例

使用路由守卫beforeEach&#xff0c;可以实现路由侦听&#xff1b; 全局侦听路由跳转的实现代码&#xff1a; app.vue onLaunch: function(e) {this.$router.beforeEach((to, from, next) > {console.log($router,to,from);next();}); } to 是跳转路由之后的page对象&am…

Debug模式下加载文件,运行程序异常的慢

今天在进行单元测试的时候&#xff0c;debug模式下加载速度很慢&#xff0c;但是run模式下速度很快。 原因&#xff1a;在debug模式下&#xff0c;断点位置不当&#xff0c;解决办法 移除编译器中的所有断点。转载于:https://www.cnblogs.com/nww57/p/5277113.html

如何在Python中对字符串进行子字符串化

Python offers many ways to substring a string. It is often called ‘slicing’.Python提供了许多对字符串进行子字符串化的方法。 它通常被称为“切片”。 It follows this template:它遵循以下模板&#xff1a; string[start: end: step]Where,哪里&#xff0c; start:…

HttpPost导包遇到的问题

直接在当前项目 build.gradle文件修改如下 android { useLibrary org.apache.http.legacy compileSdkVersion 24 buildToolsVersion "24.0.0" defaultConfig { applicationId "com.ican.subjects" minSdkVe…

真相也许是这样

这两天同学们陆续上传了自己编写的小程序&#xff0c;等老师审查给成绩的时候才发现一部分同学是负分。原因就是他们有抄袭之嫌。恰巧我当时就在一位得了负分的同学旁边&#xff0c;他一脸郁闷的对我说”没道理啊&#xff0c;这是我自己编的啊“。这个我知道&#xff0c;的确是…

微信小程序全局监听路由变化

小程序有一个API可以侦听全局路由跳转&#xff0c;官方文档里面没有但是可以使用。 wx.onAppRoute((res) > { console.log(路由监听,{res}) })

c语言面向对象编程中的类_C ++中的面向对象编程

c语言面向对象编程中的类Object oriented programming, OOP for short, aims to implement real world entities like inheritance, hiding and polymorphism in programming. 面向对象的编程&#xff0c;简称OOP&#xff0c;旨在在编程中实现诸如继承&#xff0c;隐藏和多态性…

Maven build标签

前言&#xff1a; <build >设置&#xff0c;主要用于编译设置 1.分类 在Maven的pom.xml文件中&#xff0c;存在如下两种<build>&#xff1a; &#xff08;1&#xff09;全局配置&#xff08;project build&#xff09; 针对整个项目的所有情况都有效 &#xff08;2…

Ant Design Vue 表格内编辑(附完整源码及效果图)

效果图&#xff1a; 实现关键代码就是表单的 columns 属性对象下标的 scopedSlots&#xff1a; scopedSlots: {customRender: } 实现完整代码&#xff1a; <template><div><div class"table-wrapper"><!--每个列的宽度必须比列名总长度大才能…

shell基本用法

#!/bin/bash #使用哪个shell执行echo "hello world" username"tom" echo $username#chmod x ./test.sh 设置可以执行文件#for循环输出 for skill in Ada Coffe Action Java; doecho "I am good at ${skill}Script" done #for file in ls /etc; d…

brad wu_一百万归功于Brad Traversy

brad wuBrad Traversy is one of the most appreciated web development teachers on YouTube and he is getting close to 1 Million subscribers. We decided to help him reach this goal by the end of 2019.布拉德特拉弗西 ( Brad Traversy)是YouTube上最受赞赏的网络开发…

CSS常见布局解决方案

最近要准备移动端项目&#xff0c;大半年没好好写过CSS了&#xff0c;今天恶补了一下CSS的一些布局&#xff0c;下面做一些分享。 水平居中布局 1.margin 定宽 <div class"parent"><div class"child">Demo</div> </div><style…

java.io.EOFException java.io.ObjectInputStream$PeekInputStream.readFully 错误

omcat 启动时报以下错误: java.io.EOFException at java.io.ObjectInputStream$PeekInputStream.readFully 错误 这个错误 碰到好几次了&#xff0c;我的tomcat使用非常频繁&#xff0c;而且部署项目比较多&#xff0c;经常会出一些自己看不懂的问题&#xff0c; 今天解决了这…

SQL替换字段中部分字符

示例&#xff1a; tb_item表中image字段中一数据为&#xff1a;jd/4ef8861cf6854de9889f3db9b24dc371.jpg update tb_item set image replace(image,jd,taobao); 替换后: taobao/4ef8861cf6854de9889f3db9b24dc371.jpg

flexbox_Flexbox中的Flex基础属性

flexbox弹性基础 (Flex Basis) The flex-basis property defines the size of the flex-item along the main axis of the flex container. The main axis is horizontal if flex-direction is set to row and it’ll be vertical if the flex-direction property is set to co…

OpenStack之虚拟机热迁移

这里的环境是centos7版本&#xff0c;openstack K版 1.在各个计算节点设置权限 chmod 755 /var/lib/nova/instances 2.修改各个节点的nova.conf(/etc/nova/nova.conf) vncserver_proxyclient_address虚拟机IP # vncserver_listen0.0.0.0 3.修改所有计算节点libvirt 3.1 修改/e…

软件工程概论个人作业02

可怜的二柱子同学&#xff0c;老师又对他的自动出题系统提出了新的要求&#xff1a; 1、题目避免重复&#xff1b; 2、可定制&#xff08;数量/打印方式&#xff09;&#xff1b; 3、可以控制下列参数: 是否有乘除法&#xff1b; 是否有括号(最多可以支持十个数参与计算)&#…

前端开发学习常用网站网址及介绍(都是免费的)

在开发的时候&#xff0c;想记住所有的单词基本是不可能的&#xff0c;所以就需要进入文档&#xff0c;只要理清需求能做出来&#xff0c;就很不差了&#xff01;&#xff01; 扫码加博主微信 1.百度&#xff0c;俗称度娘&#xff0c;有不懂的就问百度&#xff0c;有问必答&am…

sql语句语法多表关联_SQL Delete语句-如何删除行或表,语法示例

sql语句语法多表关联To delete a record in a table you use the DELETE statement.要删除表中的记录&#xff0c;请使用DELETE语句。 Be careful. You can delete all records of the table or just a few. Use the WHERE condition to specify which records do you wan…

数据库 大数据访问及分区分块优化方案

本文导读&#xff1a;当系统要满足每秒数万次的读写请求的需求时&#xff0c;我们可以用分布式计算、编写优良的程序代码、对海量数据进行分区操作、建立广泛的索引、建立缓存机制、加大虚拟内存、分批处理、使用数据仓库和多维数据库存储、使用负载均衡技术、将数据库的读写分…

每周算法讲堂 floyd

http://www.bilibili.com/video/av4108914/ 转载于:https://www.cnblogs.com/qscqesze/p/5284554.html

小程序云开发常用语句宝库

查询语句&#xff0c;返回的是 res.data[] 数组 调用云函数返回的是res.result get 数据获取返回的是 res.data{} 对象 1.调用云函数 this.DB wx.cloud.database() wx.cloud.init({env: mm-4t7rg }) wx.cloud.callFunction({name: "login",data: {},success(res)…

初学api测试_面向初学者的API-在此免费视频课程中学习如何使用API

初学api测试What exactly is an API? How do you use an API? Weve just published a full beginners course about Application Programming Interfaces (APIs) on the freeCodeCamp.org YouTube channel.API到底是什么&#xff1f; 您如何使用API​​&#xff1f; 我们刚刚…

整理Simple.Data使用方法

官方:http://simplefx.org/simpledata/docs/index.html Insert var user db.Users.Insert(Name: "Ford", Password: "hoopy", Age: 29);var user new User {Name "Zaphod", Password "zarquon", Age 42}; var actual db.Users.I…

css3之border-radius理解

在日常项目过程中&#xff0c;border-radius这个属性算是非常常用的属性之一了&#xff0c;通过设置元素的border-radius值&#xff0c;可以轻松给元素设置圆角边框&#xff0c;甚至实现绘制圆、半圆、四分之一的圆等各种圆角图形。 通常我在使用这个属性的时候&#xff0c;一般…

deepLink iOS 应用到自己APP 记录

1.了解deeplink 详细的介绍可以在网上查询,这里简单说一下.这项技术主要是为了方便广告跳转而产生的.最大的例子就是淘宝,天猫,京东等购物APP.在第三方APP中点击广告链接直接跳转到对应的客户端的商品的详情中,节省用户的时间,一步到位. 2.自己APP实现deeplink需要的准备工作…