Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 6283 | Accepted: 2643 |
Description
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
不错的最小覆盖路径入门题
题意:出租车公司有订单,订单时间,订单开始XY 订单结束XY
行驶时间是曼哈顿路径
如果第一单跑完后能在第二单预定前1分钟到达目的地的话。那么跑第一单的出租车可以继续跑第二单
问有多少出租车才能跑完所有单
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct Orzpoint{
int st,et;
int sx,sy;
int ex,ey;
};
int n,m;
bool imap[555][555],d[555];
int s[555];
bool findOrz(int k){
int i;
for(i=0;i<n;i++){
if(!d[i]&&imap[k][i]){
d[i]=1;
if(s[i]==-1||findOrz(s[i])){
s[i]=k;
return true;
}
}
}
return false;
}
int main(){
int i,j,k,l,t1,t2,t,orz;
int a,b,c,dd,e,f,g;
Orzpoint point[555];
scanf("%d",&t);
while(t--){
scanf("%d",&n);
memset(s,-1,sizeof(s));
memset(imap,0,sizeof(imap));
for(i=0;i<n;i++){
scanf("%d:%d%d%d%d%d",&a,&b,&point[i].sx,&point[i].sy,&point[i].ex,&point[i].ey);
point[i].st=a*60+b;
point[i].et=abs(point[i].sx-point[i].ex)+abs(point[i].sy-point[i].ey)+point[i].st;
}
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(point[i].et+1+abs(point[i].ex-point[j].sx)+abs(point[i].ey-point[j].sy)<=point[j].st){
imap[i][j]=1;
}
}
}
int ans=0;
for(i=0;i<n;i++){
memset(d,0,sizeof(d));
if(findOrz(i)){
ans++;
}
}
printf("%d\n",n-ans);
}
}