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);
}
}