Taxi Cab Scheme

Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 712 Accepted Submission(s): 337

Problem 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
2
2
08:00 10 11 9 16
08:07 9 16 10 11
2
08:00 10 11 9 16
08:06 9 16 10 11
Sample Output
1
2
Source
#include<stdio.h>
#include<string.h>
struct nn
{
int st,endt;
int x1,y1,x2,y2;
}node[505];
int vist[505],match[505],map[505][505],M;
int find(int i)
{
for(int j=1;j<=M;j++)
if(vist[j]==0&&map[i][j])
{
vist[j]=1;
if(match[j]==0||find(match[j]))
{
match[j]=i; return 1;
}
}
return 0;
}
int abs(int a)
{
return a>0?a:-a;
}
int main()
{
int t,h,f;
scanf("%d",&t);
while(t--)
{
scanf("%d",&M);
for(int i=1;i<=M;i++)
{
scanf("%d:%d %d%d%d%d",&h,&f,&node[i].x1,&node[i].y1,&node[i].x2,&node[i].y2);
node[i].st=h*60+f;
node[i].endt=node[i].st+abs(node[i].x1-node[i].x2)+abs(node[i].y1-node[i].y2);
}
memset(map,0,sizeof(map));
for(int i=1;i<=M;i++)
for(int j=1;j<=M;j++)
if(j!=i&&node[i].endt+abs(node[j].x1-node[i].x2)+abs(node[j].y1-node[i].y2)<node[j].st)
map[i][j]=1;
int ans=0;
memset(match,0,sizeof(match));
for(int i=1;i<=M;i++)
{
memset(vist,0,sizeof(vist));
ans+=find(i);
}
printf("%d\n",M-ans);
}
}

hdu1350Taxi 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. 【HDU1960】Taxi Cab Scheme(最小路径覆盖)

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

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

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

  6. POJ:2060-Taxi Cab Scheme(最小路径覆盖)

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

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

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

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

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

  9. UVAlive3126 Taxi Cab Scheme(DAG的最小路径覆盖)

    题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=32568 [思路] DAG的最小路径覆盖. 将每个人看做一个结点,如 ...

随机推荐

  1. 【rope】bzoj1269 [AHOI2006]文本编辑器editor

    维护一个字符串,支持以下操作:   主要就是 成段插入.成段删除.成段翻转.前两个操作很好通过rope实现.第三个操作也不难,维护两个rope,一个正向,一个反向,翻转时swap一下就行了.   ro ...

  2. 操作系统--IO系统任务简述

    内核IO---操作系统对于IO的职责 1.对文件和设备命名空间的管理 2.文件和设备访问的控制 3.IO操作控制 4.文件系统的空间分配 5.设备分配 6.IO缓冲管理 7.IO调度方式 8.设备状态 ...

  3. JS小游戏寻找房祖名

    提示:1:先把两个图片放到重命名并放到相应的路径内. 2:本小游戏只为闲事练手,如有小bug自行解决,解决不了的可以留言,我看到后解决. 代码如下: <!DOCTYPE html>< ...

  4. Visual Studio Code 安装 RUST

    1.下载RUST源码 https://static.rust-lang.org/dist/rustc-1.18.0-src.tar.gz ,解压到C盘   C:\rustc-1.18.0-src 2. ...

  5. java多线程之Concurrent包

    1.在新增的Concurrent包中,BlockingQueue很好的解决了多线程中,如何高效安全“传输”数据的问题. 2.通过这些高效并且线程安全的队列类,为我们快速搭建高质量的多线程程序带来极大的 ...

  6. OM-销售订单行【订购项目】配置参数文件控制

    ONT_RESTRICT_CUST_ITEMS OM:限制行层收货地址的客户项目 ONT_USE_MVIEW_FOR_ITEMS_LOV OM:为项目值列表使用物化视图(遵守项目可订购性规则)

  7. 如何获取gcr等镜像

    在cloud.docker.com上注册一个用户,然后登录 然后在github.com上注册一个用户 通过github Desktop建立一个repository,同时加入一个Dockerfile,然 ...

  8. iOS:转载:同步、异步、并行、串行的详解

    理解 iOS 开发中 GCD 相关的同步(synchronization)\ 异步(asynchronization),串行(serial)\ 并行(concurrency)概念 2014年11月21 ...

  9. Spring与Quartz的整合

    Quartz Quartz是一个完全由Java编写的开源作业调度框架,为在Java应用程序中进行作业调度提供了简单却强大的机制.Quartz允许开发人员根据时间间隔来调度作业.它实现了作业和触发器的多 ...

  10. Weblogic常见故障之二:XAER_NOTA XAException问题的解决

    在weblogic执行XA操作的时候,我们会碰到如下的错误,后来发现是JDBC配置的问题.主要报错:java.sql.SQLException: XA error: XAER_NOTA : The X ...