Assign n tasks to M machines, specify the number of days required for each task (no consecutive days required), and the days in which the task can be performed, and determine whether a solution exists.
Typical task (x) ---- the maximum stream of the second minute of the day (y) (because the task is related to the day) the processor controls the traffic. The source point is directed to the X point, which refers to the number of days required, task XI, which can be connected to a single day, with traffic 1. The traffic of each Y-part is m, indicating that a maximum of M machines are used in the current day.
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++); }}