There are n tasks, giving the departure time, departure point and destination of each task.
When a task is completed, if the current time + time to arrive at the departure point of another task <= the departure time of the other task-1, then you can let this person go on to complete the task.
Ask at least how many people you need to get the job done.
Problem solving ideas: This problem and poj-3216 repairing company very much like
Both point sets are tasks, and if a task is completed and another task can be completed next, then there is a relationship between the two tasks, so that the dichotomy is built
Because all the tasks are to be completed, that is, to cover all the points, it becomes a two-minute map of the minimum path covering the
#include <cstdio>#include <cstring>#include <vector>#include <cstdlib>using namespace STD;Const intN =510;structTime {intH, M, A, B, C, D;} Time[n];intVis[n], link[n], N; vector<int>G[n];BOOLJudgeintIintj) {intt =ABS(TIME[I].A-TIME[I].C) +ABS(TIME[I].B-TIME[I].D) +ABS(TIME[J].A-TIME[I].C) +ABS(TIME[J].B-TIME[I].D);if(Time[j].h * -+ TIME[J].M-(time[i].h * -+ time[i].m + t) >=1)return true;return false;}BOOLDfsintu) { for(inti =0; I < g[u].size (); i++) {intv = g[u][i];if(Vis[v])Continue; VIS[V] =1;if(Link[v] = =-1|| DFS (Link[v])) {Link[v] = u;return true; } }return false;}voidHungary () {intAns =0; for(inti =0; I < n; i++) {memset(Vis,0,sizeof(VIS));if(Dfs (i)) ans++; }printf("%d\n", N-ans);}voidInit () {scanf("%d", &n); for(inti =0; I < n; i++) {scanf("%d:%d%d%d%d%d", &time[i].h, &TIME[I].M, &time[i].a, &time[i].b, &time[i].c, &TIME[I].D); } for(inti =0; I < n; i++) {g[i].clear (); for(intj =0; J < N; J + +) {if(I! = J && Judge (I,j)) {G[i].push_back (j); } } }memset(Link,-1,sizeof(link));}intMain () {intTestscanf("%d", &test); while(test--) {init (); Hungary (); }return 0;}
POJ-2060 Taxi Cab Scheme dichotomy minimum path overlay