POJ-2060 Taxi Cab Scheme dichotomy minimum path overlay

Source: Internet
Author: User

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, &AMP;TIME[I].M, &time[i].a, &time[i].b, &time[i].c, &AMP;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

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.