Description

Running a taxi station is not all that simple. Apart from the obvious demand for a centralised coordination of the cabs in order to pick up the customers calling to get a cab as soon as possible,there is also a need to schedule all the taxi rides which have been booked in advance.Given a list of all booked taxi rides for the next day, you want to minimise the number of cabs needed to carry out all of the rides. 
For the sake of simplicity, we model a city as a rectangular grid. An address in the city is denoted by two integers: the street and avenue number. The time needed to get from the address a, b to c, d by taxi is |a - c| + |b - d| minutes. A cab may carry out a booked ride if it is its first ride of the day, or if it can get to the source address of the new ride from its latest,at least one minute before the new ride’s scheduled departure. Note that some rides may end after midnight. 
Input

On the first line of the input is a single positive integer N, telling the number of test scenarios to follow. Each scenario begins with a line containing an integer M, 0 < M < 500, being the number of booked taxi rides. The following M lines contain the rides. Each ride is described by a departure time on the format hh:mm (ranging from 00:00 to 23:59), two integers a b that are the coordinates of the source address and two integers c d that are the coordinates of the destination address. All coordinates are at least 0 and strictly smaller than 200. The booked rides in each scenario are sorted in order of increasing departure time. 
Output

For each scenario, output one line containing the minimum number of cabs required to carry out all the booked taxi rides. 
Sample Input



08:00 10 11 9 16 
08:07 9 16 10 11 

08:00 10 11 9 16 
08:06 9 16 10 11 
Sample Output

1

题意是说有n个出车安排,一辆车能接到这个安排的条件是:1、这辆车第一次发车;2、这辆车接了上一个安排,回到这个安排的起点的时间正好是这个安排的前一分钟或者更早 
每一次安排有五个输入数据,第一个是发车时间,2、3是起点位置,4、5是终点位置,因此计算每两个安排之间的时间差可以用第一个的最后两个数和第二个的第二和三个数。我一开始就是这里没明白才不知道怎么算两个安排之间的关系 
接下来就是用二分图,把每个安排都放在二分图的两个点集上,显然两个相同的任务之间不会有边,只有符合题意的两个不同的任务可以连一条边

以上内容来自 https://blog.csdn.net/blue_skyrim/article/details/51331383

跑一边匈牙利就直接出来了  这个的数据量小  暴力也可以出来

 #include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <algorithm>
#include <set>
#include <iostream>
#include <map>
#include <stack>
#include <string>
#include <vector>
#define pi acos(-1.0)
#define eps 1e-6
#define fi first
#define se second
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define bug printf("******")
#define mem(a,b) memset(a,b,sizeof(a))
#define fuck(x) cout<<"["<<x<<"]"<<endl
#define f(a) a*a
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pf printf
#define FRE(i,a,b) for(i = a; i <= b; i++)
#define FREE(i,a,b) for(i = a; i >= b; i--)
#define FRL(i,a,b) for(i = a; i < b; i++)
#define FRLL(i,a,b) for(i = a; i > b; i--)
#define FIN freopen("in.txt","r",stdin)
#define lowbit(x) x&-x
#pragma comment (linker,"/STACK:102400000,102400000")
using namespace std;
const int maxn = ;
typedef long long LL;
int cas, n, vis[], mp[][], match[], dfscnt;
struct node {
int time, a, b, c, d, later;
} qu[maxn];
int cal(int x1, int y1, int x2, int y2) {
return abs(x1 - x2) + abs(y1 - y2);
}
int dfs(int rt) {
for (int i = ; i <= n ; i++) {
if (mp[rt][i]) {
if (vis[i] != dfscnt) {
vis[i] = dfscnt;
if (!match[i] || dfs(match[i])) {
match[i] = rt;
return ;
}
}
}
}
return ;
} int main() {
scanf("%d", &cas);
while(cas--) {
scanf("%d", &n);
mem(vis, );
mem(mp, );
mem(match, );
dfscnt = ;
for (int i = ; i <= n ; i++) {
int x, y;
scanf("%d:%d %d%d%d%d", &x, &y, &qu[i].a, &qu[i].b, &qu[i].c, &qu[i].d);
qu[i].time = x * + y;
qu[i].later = qu[i].time + cal(qu[i].a, qu[i].b, qu[i].c, qu[i].d);
}
for (int i = ; i <= n ; i++)
for (int j = i ; j <= n; j++)
if (qu[i].later + cal(qu[i].c, qu[i].d, qu[j].a, qu[j].b) < qu[j].time) mp[i][j] = ;
int ans = ;
for (int i = ; i <= n ; i++) {
dfscnt++;
if (dfs(i)) ans++;
}
printf("%d\n", n - ans);
}
return ;
}

poj2060——Taxi Cab Scheme(最小路径覆盖)的更多相关文章

  1. poj 2060 Taxi Cab Scheme (最小路径覆盖)

    http://poj.org/problem?id=2060 Taxi Cab Scheme Time Limit: 1000MS   Memory Limit: 30000K Total Submi ...

  2. UVaLive 3126 Taxi Cab Scheme (最小路径覆盖)

    题意:有 n 个客人,要从 si 到 ti,每个人有一个出发时间,现在让你安排最少和出租车去接,在接客人时至少要提前一分钟到达客人的出发地点. 析:把每个客人看成一个结点,然后如果用同一个出租车接的话 ...

  3. UVALive3126 Taxi Cab Scheme —— 最小路径覆盖

    题目链接:https://vjudge.net/problem/UVALive-3126 题解: 最小路径覆盖:即在图中找出尽量少的路径,使得每个结点恰好只存在于一条路径上.其中单独一个点也可以是一条 ...

  4. hdu1350Taxi Cab Scheme (最小路径覆盖)

    Taxi Cab Scheme Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...

  5. 二分图最小路径覆盖--poj2060 Taxi Cab Scheme

    Taxi Cab Scheme 时间限制: 1 Sec  内存限制: 64 MB 题目描述 Running a taxi station is not all that simple. Apart f ...

  6. 【HDU1960】Taxi Cab Scheme(最小路径覆盖)

    Taxi Cab Scheme Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  7. Taxi Cab Scheme UVALive - 3126 最小路径覆盖解法(必须是DAG,有向无环图) = 结点数-最大匹配

    /** 题目:Taxi Cab Scheme UVALive - 3126 最小路径覆盖解法(必须是DAG,有向无环图) = 结点数-最大匹配 链接:https://vjudge.net/proble ...

  8. UVA 1201 - Taxi Cab Scheme(二分图匹配+最小路径覆盖)

    UVA 1201 - Taxi Cab Scheme 题目链接 题意:给定一些乘客.每一个乘客须要一个出租车,有一个起始时刻,起点,终点,行走路程为曼哈顿距离,每辆出租车必须在乘客一分钟之前到达.问最 ...

  9. Taxi Cab Scheme POJ - 2060 二分图最小路径覆盖

    Running a taxi station is not all that simple. Apart from the obvious demand for a centralised coord ...

随机推荐

  1. JavaScript --经典问题

    JavaScript中如何检测一个变量是一个String类型?请写出函数实现 方法1. function isString(obj){ return typeof(obj) === "str ...

  2. Windows10安装GPU版本的Tensorflow

    本人电脑配置(公司的)gtx1080ti,下载的的cuda8.0,cudnn6.0,python3.5.3安装完成后,安装tensorflow 1.pip install tensorflow-gpu ...

  3. OpenMPI源码剖析1:MPI_Init初探

    OpenMPI的底层实现: 我们知道,OpenMPI应用起来还是比较简单的,但是如果让我自己来实现一个MPI的并行计算,你会怎么设计呢?————这就涉及到比较底层的东西了. 回想起我们最简单的代码,通 ...

  4. 开源自动驾驶仿真平台 AirSim (2) - 编译 AirSim

    AirSim 的官方 Github: https://github.com/Microsoft/AirSim 对于 Unreal Engine 来说,AirSim 其实是作为一个插件存在,说白了就是把 ...

  5. Machine Learning笔记整理 ------ (三)基本性能度量

    1. 均方误差,错误率,精度 给定样例集 (Example set): D = {(x1, y1), (x2, y2), (x3, y3), ......, (xm, ym)} 其中xi是对应属性的值 ...

  6. 浅谈CPU、内存、硬盘之间的关系

    计算机,大家都知道的,就是我们日常用的电脑,不管台式的还是笔记本都是计算机.那么这个看着很复杂的机器由哪些组成的呢,今天就简单的来了解一下. 先放图: 图上展示的就是计算机的基本组成啦. 首先是输入设 ...

  7. Python-期末练习

    1.骑车与走路:我们的校园很大很大很大大大大大……,骑个自行车去办事会很快,比如取个快递了,到其他宿舍楼找个同(nv)学(you)了.但实际上,并非去办任何事情都是骑车快,因为骑车总要找车.开锁.停车 ...

  8. 苹果IOS、安卓推送功能开发

    IOS推送开发:以下是基于开源javapns推送开发1.DerInputStream.getLength(): lengthTag=111, too big.先排除是否由于打包时证书 .p12 文件被 ...

  9. get computer system mac info in javascript

    get computer system mac info in javascript Q: how to using js get computer system mac information? A ...

  10. winform中文本框添加拖拽功能

    对一个文本框添加拖拽功能: private void txtFolder_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataP ...