"Maximum Flow" XMU 1595 machine scheduling

Source: Internet
Author: User

Topic Links:

http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1595

Main Topic :

T Group data, n tasks, M machines, for each task: there is a processing time p (indicates that the task requires the machine to work p days to complete), a release time R (indicates that the task needs to start from the R day to be processed), a completion time D (indicates that the task must be completed before the D Day) Guarantee: D >= p + r. A task can only be run on one machine at a time, but the runtime may be interrupted and moved to another machine. For each machine: at most one task at a time, you can handle different tasks at different times. Ask if there is a scheduling scheme so that all tasks can be completed smoothly?

Topic Ideas:

  "Maximum Flow"

It doesn't look as if it's a network flow problem.

The number of times that the task and the task can run, s to the task's connection time, and the time to the T-connected machine.

Bare maximum flow.

1 //2 //by Coolxxx3 //4#include <iostream>5#include <algorithm>6#include <string>7#include <iomanip>8#include <memory.h>9#include <time.h>Ten#include <stdio.h> One#include <stdlib.h> A#include <string.h> -#include <stdbool.h> -#include <math.h> the #defineMin (a) < (b) ( A):(B)) - #defineMax (a) (a) > (b)? ( A):(B)) - #defineABS (a) ((a) >0? ( A):(-(a))) - #defineLowbit (a) (a& (a)) + #defineSqr (a) ((a) * (a)) - #defineSwap (a) (a) ^= (b), (b) ^= (a), (a) ^= (b)) + #defineEPS 1e-8 A #defineJ 10 at #defineMAX 0x7f7f7f7f - #definePI 3.1415926535897 - #defineINF 10000000 - #defineN 504 - #defineM 50004 - using namespacestd; in intN,m,lll,ans,cas; - intnn,fl,s,t; to intLast[n],d[n],vd[n]; + structXXX - { the     intnext,e,q; * }a[m]; $ voidAddintXintYintz)Panax Notoginseng { -a[++lll].next=Last[x]; theA[lll].e=y; +a[lll].q=Z; Alast[x]=lll; the } + intSapintUintf) - { $     inti,v,tt,asp=0, mix=nn-1; $     if(u==t)returnF; -      for(i=last[u];i!=0; i=a[i].next) -     { thev=a[i].e; -         if(a[i].q>0)Wuyi         { the             if(d[u]==d[v]+1) -             { WuTt=sap (V,min (fasp,a[i].q)); -asp+=tt; Abouta[i].q-=tt; $a[i^1].q+=tt; -                 if(Asp==f | | d[s]==nn) -                     returnASP; -             } Amix=min (mix,d[v]); +         } the     } -     if(asp!=0)returnASP; $     if(!--Vd[d[u]]) d[s]=nn; the     Elsevd[d[u]=mix+1]++; the     returnASP; the } the voidbuild () - { in     inti,j,x,y,z; thes= -+ $+1; t= -+ $+2; thenn=0; About      for(i=1; i<=n;i++) the     { thescanf"%d%d%d",&x,&y,&z); thefl+=x;nn=Max (nn,z); +Add (s,i,x); Add (I,s,0); -          for(j=y;j<z;j++) the         {BayiAdd (I,n+j,1); Add (N+j,i,0); the         } the     } -      for(i=1; i<=nn;i++) -     { theAdd (n+i,t,m); Add (T,n+i,0); the     } thenn+=n+2; thevd[0]=nn; - } the intMain () the { the #ifndef Online_judge94 //freopen ("1.txt", "R", stdin); the //freopen ("2.txt", "w", stdout); the     #endif the     inti,j,k,l,f;98 //while (~scanf ("%s", S1)) About //while (~scanf ("%d", &n)) -      for(SCANF ("%d", &cas), l=1; l<=cas;l++)101     {102fl=ans=0; lll=1;103memset (D,0,sizeof(d));104memset (VD,0,sizeof(VD)); theMemset (Last,0,sizeof(last));106scanf"%d%d",&n,&m);107 build ();108          while(d[s]<nn)109         { thef=SAP (S,MAX);111ans+=F; the         }113         if(ANS==FL) puts ("Yes"); the         ElsePuts"No"); the     } the     return 0;117 }118 119 /* - //121 122 //123 */
View Code

"Maximum Flow" XMU 1595 machine scheduling

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.