Poj2060--taxi Cab Scheme (minimum path overlay)

Source: Internet
Author: User

Description

Running A taxi station isn't all. Apart from the obvious demand for a centralised coordination of the cabs in order to pick up the customers calling to get A cab as soon as Possible,there is also a need to schedule all the taxi rides which has 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 off all of The rides.
For the sake of simplicity, we model a city as a rectangular grid. An address in the city was denoted by the 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's it's first ride of the day, or if it can get to the source address of the new RI De from its latest,at least one minute before the new ride ' s scheduled departure. Note that some rides may end after midnight.
Input

On the first line of the input was a single positive integer N, telling the number of the test scenarios to follow. Each scenario begins with a line containing an integer M, 0 < M <, being the number of booked taxi rides. The following M lines contain the rides. Each ride was described by a departure time on the format hh:mm (ranging from 00:00 to 23:59), and the other integers a b that was th e coordinates of the source address and integers C d that is the coordinates of the destination address. All coordinates is at least 0 and strictly smaller than 200. The booked rides in each scenario is sorted in order of increasing departure time.
Output

For each scenario, output one line containing the minimum number of cabs required to carry out all the booked taxi rides.
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

Test instructions is said to have n out of the car arrangement, a vehicle can receive this arrangement of conditions are: 1, the car first departure; 2, the car connected to the last arrangement, the time to return to the beginning of this arrangement is exactly the first minute or earlier of this arrangement
Each schedule has five input data, the first is the departure time, 2, 3 is the starting position, 4, 5 is the end position, so the calculation of the time difference between each two arrangement can be the last two number of the first and the second second and three numbers. I don't know how to figure out how to count the relationship between two arrangements in the first place.
Next is to use a binary graph, each arrangement is placed in the two point set of two points, it is obvious that there is no edge between the two identical tasks, only two different tasks that meet test instructions can be connected to one side

#include <stdio.h>#include <string.h>#include <algorithm>#include <queue>#include <vector>#include <iostream>#include <set>#include <cstring>#include <string>#define MAXN 510#define INF 0xFFFFFFFFusing namespace STD;structnode{intA,b,c,d;intBegin;}; Node S[MAXN];intNintGet_map (intIintj) {if(I==J)return 0;inttmp=ABS(S[I].A-S[I].C) +ABS(S[I].B-S[I].D) +s[i].begin; tmp+=ABS(S[I].C-S[J].A) +ABS(S[I].D-S[J].B);if(Tmp<s[j].begin)return 1;Else        return 0;}BOOLVIS[MAXN];int Map[MAXN] [MAXN],PRE[MAXN];//matching path;intFindintcur) { for(intI=1; i<=n; ++i) {if(!vis[i]&&Map[cur] [i]) {vis[i] =true;if(Pre[i] = =0|| Find (Pre[i])) {pre[i] = cur;return 1; }        }    }return 0;}intMain () {intT,h,m;scanf("%d", &t); while(t--) {memset(Map,0,sizeof(Map));scanf("%d", &n); for(intI=1; i<=n; ++i) {scanf("%d:%d", &h,&m); s[i].begin=h* -+m;scanf("%d%d%d%d", &AMP;S[I].A,&AMP;S[I].B,&AMP;S[I].C,&AMP;S[I].D); } for(intI=1; i<=n; ++i) for(intj=1; j<=n; ++J)MapI [J]=get_map (I,J);memset(Pre,0,sizeof(pre));intnum=0; for(intI=1; i<=n; ++i) {memset(Vis,0,sizeof(VIS));if(Find (i)) num++; }printf("%d\n", N-num); }return 0;}

Poj2060--taxi Cab Scheme (minimum path overlay)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.