Poj3216repairing company binary matching minimum path overlay +floyd

Source: Internet
Author: User

//m tasks, each task has a start time and need to spend time, and where the building where the work//Give the map, the time spent on the path of each floor to the other floor//Ask at least how many people will be able to complete these tasks//To create a diagram between tasks and tasks, if I can do the task I still do the tasks J so i-j build an edge between the two//This only requires finding the minimum path overlay as the final answer#include <cstdio>#include <iostream>#include <cstring>using namespace STD;Const intMAXN = About;Const intINF =0x3f3f3f3f;int Map[MAXN] [MAXN];intVIS[MAXN];intMATCH[MAXN];intDIS[MAXN][MAXN];structnode{intSt, id, ti;} T[MAXN];intN, M;voidFloyd () { for(intK =1; k <= n;k++) for(inti =1; I <= n;i++) for(intj =1; J <= n;j++) dis[i][j] = min (Dis[i][k] + dis[k][j], dis[i][j]);}BOOLFindintST) { for(inti =1; I <= m;i++) {if(!vis[i] &&Map[St] [i]) {Vis[i] =1;if(Match[i] = =-1|| Find (Match[i])) {Match[i] = st;return true; }       }    }return false;}intMain () { while(scanf("%d%d", &n, &m) && (n+m)) {memset(Match,-1,sizeof(match)) ;memset(Map,0,sizeof(Map)) ; for(inti =1; I <= n;i++) for(intj =1; J <= n;j++) {scanf("%d", &dis[i][j]);if(Dis[i][j] = =-1) dis[i][j] = inf; } Floyd (); for(inti =1; I <= m;i++)scanf("%d%d%d", &t[i].id, &t[i].st, &t[i].ti); for(inti =1; I <= m;i++) { for(intj =1; J <= m;j++) {if(i = = j)Continue;if(T[i].st + T[i].ti + dis[t[i].id][t[j].id] <= t[j].st)MapI [j] =1; }        }intAns =0; for(inti =1; I <= m;i++) {memset(Vis,0,sizeof(VIS)) ;if(Find (i)) ans++; }cout<<m-ans<<endl; }return 0;}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Poj3216repairing company binary matching minimum path overlay +floyd

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.