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 ...
随机推荐
- Fiddler 无法监测WCF通信疑问
别人的可以检测到通信,我的为什么不行呢? 使用的是basicHttp协议,应该可以的啊,着的是非常奇怪
- 数据库-mongodb-常用命令
展示当前集合列表 1 show dbs 查看查询命令 1 db.stu.find().explain(); 结果中的 "cursor":"BasicCursor" ...
- POJ 1950
直接DFS,因为实在没想到什么剪枝了... 注意一点是,10.11使用的是1011哦 #include <iostream> #include <cstdio> #includ ...
- HDU 3507
斜率DP入门题.推荐看看这篇http://www.cnblogs.com/ka200812/archive/2012/08/03/2621345.html 看过之后,自己思考,发现有些不妥之处就是,其 ...
- Unable to access the IIS metabase
https://stackoverflow.com/questions/12859891/error-unable-to-access-the-iis-metabase 解决方法1 On Window ...
- 英语发音规则---B字母
英语发音规则---B字母 一.总结 一句话总结: 1.B发[b]音? bike [baɪk] n. 自行车 bus [bʌs] n. 公共汽车 bag [bæg] n. 袋:猎获物 baby ['be ...
- nginx报错日志:see security.limit_extensions
访问出现部分.js.css等部分文件被拒绝错误日志如下: 19:20:13 [error] 1181#0: *287 FastCGI sent in stderr: "Access to t ...
- 多线程与MySQL(十)
1.1 多线程 在传统操作系统中,每个进程有一个地址空间,而且默认就有一个控制线程 线程顾名思义,就是一条流水线工作的过程,一条流水线必须属于一个车间,一个车间的工作过程是一个进程 车间负责把资源整合 ...
- javascript中document.getElementsByClassName兼容性封装方法一
var getElmsByClsName = function(className, results) { results = results || []; // 判断浏览器是否支持 getEleme ...
- PopupWindow实现点击外部不消失
View contentView = LayoutInflater.from(MainActivity.this).inflate(R.layout.alert_ip, null); final Po ...