//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