HDU 1350 Taxi Cab Scheme
Taxi Cab Scheme
This problem will be judged on HDU. Original ID: 1350
64-bit integer IO format: %I64d Java class name: Main
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
Output
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 <bits/stdc++.h>
using namespace std;
const int maxn = ;
struct GUEST {
int s,t,x[],y[];
bool operator<(const GUEST &t) const {
return s < t.s;
}
} guest[maxn];
vector<int>g[maxn];
int Link[maxn];
bool used[maxn];
bool match(int u){
for(int i = g[u].size()-; i >= ; --i){
if(!used[g[u][i]]){
used[g[u][i]] = true;
if(Link[g[u][i]] == - || match(Link[g[u][i]])){
Link[g[u][i]] = u;
return true;
}
}
}
return false;
}
int main() {
int kase,n,h,m;
scanf("%d",&kase);
while(kase--) {
scanf("%d",&n);
for(int i = ; i < n; ++i) {
scanf("%d:%d %d %d %d %d",&h,&m,&guest[i].x[],&guest[i].y[],&guest[i].x[],&guest[i].y[]);
guest[i].s = h* + m;
guest[i].t = guest[i].s + abs(guest[i].x[] - guest[i].x[]) + abs(guest[i].y[] - guest[i].y[]);
}
sort(guest,guest+n);
for(int i = ; i < maxn; ++i) g[i].clear();
for(int i = ; i < n; ++i)
for(int j = i + ; j < n; ++j) {
int d = abs(guest[i].x[] - guest[j].x[]) + abs(guest[i].y[] - guest[j].y[]);
if(guest[i].t + d < guest[j].s) g[i].push_back(j);
}
memset(Link,-,sizeof Link);
int ret = ;
for(int i = ; i < n; ++i){
memset(used,false,sizeof used);
if(match(i)) ++ret;
}
printf("%d\n",n-ret);
}
return ;
}
HDU 1350 Taxi Cab Scheme的更多相关文章
- 1350 Taxi Cab Scheme DAG最小路径覆盖
对于什么是DAG最小路径覆盖以及解题方法在我的另外的博客已经有了.http://www.cnblogs.com/Potato-lover/p/3980470.html 此题的题意: 公交车(出租车)车 ...
- Taxi Cab Scheme POJ && HDU
Online Judge Problem Set Authors Online Contests User Web Board Home Page F.A.Qs Statistical Charts ...
- 【HDU1960】Taxi Cab Scheme(最小路径覆盖)
Taxi Cab Scheme Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- poj 2060 Taxi Cab Scheme (二分匹配)
Taxi Cab Scheme Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 5710 Accepted: 2393 D ...
- poj 2060 Taxi Cab Scheme (最小路径覆盖)
http://poj.org/problem?id=2060 Taxi Cab Scheme Time Limit: 1000MS Memory Limit: 30000K Total Submi ...
- 二分图最小路径覆盖--poj2060 Taxi Cab Scheme
Taxi Cab Scheme 时间限制: 1 Sec 内存限制: 64 MB 题目描述 Running a taxi station is not all that simple. Apart f ...
- Taxi Cab Scheme UVALive - 3126 最小路径覆盖解法(必须是DAG,有向无环图) = 结点数-最大匹配
/** 题目:Taxi Cab Scheme UVALive - 3126 最小路径覆盖解法(必须是DAG,有向无环图) = 结点数-最大匹配 链接:https://vjudge.net/proble ...
- UVA 1201 - Taxi Cab Scheme(二分图匹配+最小路径覆盖)
UVA 1201 - Taxi Cab Scheme 题目链接 题意:给定一些乘客.每一个乘客须要一个出租车,有一个起始时刻,起点,终点,行走路程为曼哈顿距离,每辆出租车必须在乘客一分钟之前到达.问最 ...
- poj2060——Taxi Cab Scheme(最小路径覆盖)
Description Running a taxi station is not all that simple. Apart from the obvious demand for a centr ...
随机推荐
- 加速 MySQL 导入导出的方法
http://www.21andy.com/new/20100917/1952.html MySQL导出的SQL语句在导入时有可能会非常非常慢,在处理百万级数据的时候,可能导入要花几小时.在导出时合理 ...
- bat执行bat文件
目的:在服务器桌面创建一个bat文件执行tomcat下的startup.bat文件,这样就不用每次都去文件夹下找startup.bat文件 桌面bat文件内容: @echo off start D:\ ...
- Hibernate-原生SQL查询
HQL尽管容易使用,但是在一些复杂的数据操作上功能有限.特别是在实现复杂的报表统计与计算,以及多表连接查询上往往无能为力,这时可以使用SQL(Native SQL)实现HQL无法完成的任务. 1.使用 ...
- 设置编码格式为utf8
response.setCharacterEncoding("UTF-8"); 在Servlet2.3中是不行的,至少要2.4版本才可以,如果低于2.4版本,可以用如下办法: re ...
- 清除eclipse中的SVN账号信息
清除eclipse中的SVN账号信息 参考了:http://blog.csdn.net/ningtieming/article/details/60469346 需要先在资源管理器中使用Tortois ...
- 网络抓包工具 Fiddler
网络抓包工具 Fiddler 下载网址 http://www.telerik.com/fiddler 简单介绍 Fiddler是一个http协议调试代理工具,它能够记录并检查全部你的电脑和互联网之间的 ...
- STM32F030, 使用嘀嗒定时器Systick实现LED闪烁
本文主要解决两个问题 1 STM32的IO口要反转,怎么实现? 2 嘀嗒定时器systick的配置 解答1: 单片机的口,反转非常easy.sbit led = P1 ^6; led = ~led; ...
- Ubuntu(64位)编译Android源码常见错误解决办法
2013年07月10日 14:47:27 阅读数:1239 错误: /usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file ...
- hdoj--1248--寒冰王座(完全背包)
寒冰王座 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submi ...
- 存储概念解析:NAS与SAN的区别
目前存储网络技术领域中的两个主旋律是SAN(存储区域网络)和NAS(网络连接区域存储),两者都宣称是解决现代企业高容量数据存储需求的最佳选择. 正如在餐厅就餐时大厨不会为您传菜,跑堂不会为您烹制鲜橙烩 ...