hdu1350Taxi Cab Scheme (最小路径覆盖)
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
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.
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.
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
1
2
#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 (最小路径覆盖)的更多相关文章
- poj 2060 Taxi Cab Scheme (最小路径覆盖)
http://poj.org/problem?id=2060 Taxi Cab Scheme Time Limit: 1000MS Memory Limit: 30000K Total Submi ...
- UVaLive 3126 Taxi Cab Scheme (最小路径覆盖)
题意:有 n 个客人,要从 si 到 ti,每个人有一个出发时间,现在让你安排最少和出租车去接,在接客人时至少要提前一分钟到达客人的出发地点. 析:把每个客人看成一个结点,然后如果用同一个出租车接的话 ...
- UVALive3126 Taxi Cab Scheme —— 最小路径覆盖
题目链接:https://vjudge.net/problem/UVALive-3126 题解: 最小路径覆盖:即在图中找出尽量少的路径,使得每个结点恰好只存在于一条路径上.其中单独一个点也可以是一条 ...
- 【HDU1960】Taxi Cab Scheme(最小路径覆盖)
Taxi Cab Scheme Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- Taxi Cab Scheme UVALive - 3126 最小路径覆盖解法(必须是DAG,有向无环图) = 结点数-最大匹配
/** 题目:Taxi Cab Scheme UVALive - 3126 最小路径覆盖解法(必须是DAG,有向无环图) = 结点数-最大匹配 链接:https://vjudge.net/proble ...
- POJ:2060-Taxi Cab Scheme(最小路径覆盖)
传送门:http://poj.org/problem?id=2060 Taxi Cab Scheme Time Limit: 1000MS Memory Limit: 30000K Total Sub ...
- UVA 1201 - Taxi Cab Scheme(二分图匹配+最小路径覆盖)
UVA 1201 - Taxi Cab Scheme 题目链接 题意:给定一些乘客.每一个乘客须要一个出租车,有一个起始时刻,起点,终点,行走路程为曼哈顿距离,每辆出租车必须在乘客一分钟之前到达.问最 ...
- Taxi Cab Scheme POJ - 2060 二分图最小路径覆盖
Running a taxi station is not all that simple. Apart from the obvious demand for a centralised coord ...
- UVAlive3126 Taxi Cab Scheme(DAG的最小路径覆盖)
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=32568 [思路] DAG的最小路径覆盖. 将每个人看做一个结点,如 ...
随机推荐
- 【凸包】【三分】Gym - 101309D - Dome of Circus
容易发现,圆锥体积和点的具体x.y坐标无关,只与其到z轴的距离sqrt(x*x+y*y)有关. 于是将这些三维的点都投射到二维的xOy平面的第二象限(sqrt(x*x+y*y),z),求个上凸壳,然后 ...
- 【动态规划】mr354-坐车看球
[题目大意] 两个球队的支持者要一起坐车去看球,他们已经排成了一列.我们要让他们分乘若干辆巴士,同一辆巴士上的人必须在队伍中是连续的.为了在车上不起冲突,希望两队的支持者人数尽量相等,差至多是D.有一 ...
- [NOIP2011]聪明的质检员
[问题描述] 小 T 是一名质量监督员,最近负责检验一批矿产的质量.这批矿产共有$n$个矿石,从 1 到$n$逐一编号,每个矿石都有自己的重量$w_i$以及价值$v_i$.检验矿产的流程是: 1. 给 ...
- 一段javascript设计模式应用场景
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <hea ...
- [典型漏洞分享]结合YS业务分析使用oauth协议的风险
结合YS业务分析oauth协议风险 问题描述: YS 使用QQ互联的openAPI实现QQ登录YS的功能,使用该功能需要在腾讯注册登录时的回调地址,根据oauth协议,用户的code或者access_ ...
- cas协议,以及tomcat搭建cas服务器
1. CAS 简介 1.1. What is CAS ? CAS ( Central Authentication Service ) 是 Yale 大学发起的一个企业级的.开源的项目,旨 ...
- Hibernate3的jar包
一.hibernate3包说明 说明: Hibernate 软件包中的Hibernate3.jar 是我们需要使用的Hibernate 工具,其他引用的 Jar 文件位于lib 子目录下,Hibern ...
- [转]Insert, Update, and Delete Destination table with SSIS
本文转自:http://www.rad.pasfu.com/index.php?/archives/150-Insert,-Update,-and-Delete-Destination-table-w ...
- ubuntu 安装ODOO时的python的依赖
sudo apt-get install graphviz ghostscript postgresql-client python-dateutil python-feedparser python ...
- tornado 多进程模式
https://www.douban.com/note/217901726/ 官方文档的helloworld实例中的启动方法: if __name__ == "__main__": ...