Serie A championship: the task of assigning N m machine. To the number of days each task takes (if not ongoing daily) and can be done on which day tasks. Ask if there is a plan.
The typical task (X)----Day (Y) Half of the maximum traffic (because this task is the relationship between days) of the processor control flow. SOURCE X Ministry of Foreign Affairs Point, it refers to a few days. Task Xi, in order to be able to do even if the day, Stream 1, a Y point to the sink point to the flow of M, indicating that day up to use M machine.
PS: note the output format
#include <iostream> #include <queue> #include <cstdio> #include <cstring>using namespace std; const int Inf=0x3f3f3f3f;const int maxv=1001,maxe=200101;int nume=0;int head[maxv];int e[maxe][3];void inline adde (int i , int j,int c) {e[nume][0]=j;e[nume][1]=head[i];head[i]=nume; E[nume++][2]=c; E[nume][0]=i;e[nume][1]=head[j];head[j]=nume; e[nume++][2]=0;} int Ss,tt,n,m,all;int vis[maxv];int Lev[maxv];bool BFS () {for (int i=0;i<maxv;i++) vis[i]=lev[i]=0; queue<int>q; Q.push (ss); Vis[ss]=1; while (!q.empty ()) {int Cur=q.front (); Q.pop (); for (int i=head[cur];i!=-1;i=e[i][1]) {int v=e[i][0]; if (!vis[v]&&e[i][2]>0) {lev[v]=lev[cur]+1; Vis[v]=1; Q.push (v); }}} return VIS[TT];} int dfs (int u,int minf) {if (u==tt| | minf==0) return minf; int sumf=0,f; for (int i=head[u];i!=-1&&minf;i=e[i][1]) {int v=e[i][0]; if (lev[v]==lev[u]+1&&e[i][2]>0) {F=dfs (v,minf<e[i][2]?minf:e[i][2]); E[i][2]-=f;e[i^1][2]+=f; Sumf+=f;minf-=f; }} if (!SUMF) lev[u]=-1; return SUMF;} int dinic () {int sum=0; while (BFS ())) Sum+=dfs (Ss,inf); return sum;} void Read_build () {int pi,si,ei; for (int i=1;i<=n;i++) {scanf ("%d%d%d", &pi,&si,&ei); All+=pi; Adde (SS,I,PI); for (int j=si;j<=ei;j++) {adde (i,n+j,1); }} for (int i=1;i<=500;i++) {adde (i+n,tt,m); }}void init () {scanf ("%d%d", &n,&m); nume=0;all=0; memset (head,-1,sizeof (head)); ss=n+501;tt=n+502;} int main () {int T; scanf ("%d", &t); int ct=1; while (t--) {init (); Read_build (); int Ans=dinic (); if (ans==all) printf ("Case%d:yes\n\n", ct++); else printf ("Case%d:no\n\n", ct++); }}
hdu3572 task allocation/maximum flow inference full flow