Task Schedule
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8610 Accepted Submission(s): 2636
Problem Description
Our geometry princess XMM has stoped her study in computational geometry to concentrate on her newly opened factory. Her factory has introduced M new machines in order to process the coming N tasks. For the i-th task, the factory has to start processing it at or after day Si, process it for Pi days, and finish the task before or at day Ei. A machine can only work on one task at a time, and each task can be processed by at most one machine at a time. However, a task can be interrupted and processed on different machines on different days. Now she wonders whether he has a feasible schedule to finish all the tasks in time. She turns to you for help.
Input
On the first line comes an integer T(T<=20), indicating the number of test cases. You are given two integer N(N<=500) and M(M<=200) on the first line of each test case. Then on each of next N lines are three integers Pi, Si and Ei (1<=Pi, Si, Ei<=500), which have the meaning described in the description. It is guaranteed that in a feasible schedule every task that can be finished will be done before or at its end day.
Output
For each test case, print “Case x: ” first, where x is the case number. If there exists a feasible schedule to finish all the tasks, print “Yes”, otherwise print “No”. Print a blank line after each test case.
Sample Input
2
4 3
1 3 5
1 1 4
2 3 7
3 5 9
2 2
2 1 3
1 2 2
Sample Output
Case 1: Yes
Case 2: Yes
Author
allenlowesy
Source
题意:
有n个任务,m台机器,给出每个任务需要耗费的时间以及能做此任务的时间点,每个任务每天只能由一台机器做,一台机器每天只能做一个任务问能否将这些任务做完
输入n,m
输入n行x,y,z表示该任务需要x天,第y天到第z天可以做这个任务
代码:
//从原点连向n个任务容量为该任务需要的时间,n个任务连向500个时间点容量为1(一个任务一天只有一台机器去做),//时间点连向汇点,容量为机器数m(一台机器一天只能做一个任务),求最大流是否等于完成所有任务的天数。#include#include #include #include #include using namespace std;const int maxn=2009;const int inf=0x7fffffff;struct Edge{ int from,to,cap,flow; Edge(int u,int v,int c,int f):from(u),to(v),cap(c),flow(f){}};struct Dinic{ int n,m,s,t; vector edges; vector g[maxn]; bool vis[maxn]; int d[maxn]; int cur[maxn]; void Init(int n){ this->n=n; for(int i=0;i