Factory Pipelining
时间限制: 1 Sec 内存限制: 64 MB
提交: 16 解决: 4
[提交][状态][讨论版]
题目描述
In modern factory production, pipelining mode(流水线生产) plays a quite important role. Only reasonable arrangement on tasks can assure a high level production efficiency. Now, the planners provide their manual arranged pipelining schedule table. But as there are too many machines and working procedures(工序), checking whether the schedule really works is not easy for them. So can you write a program to help them?
The pipelining mode follows these rules:
The products are produced and assembled(组装) step by step. The producing process strictly follows working procedures, which means only when all parts(零件) that the current procedure needed have finished their previous procedure, can the current procedure be carried out. And the previous part only can be produced or assembled by one part. Every machine starts at the same time and the pipelining mode strictly follows time order, that is they can’t be forced to wait.
输入
There is a positive integer t(t<=200) on the first line, indicating the case number. There follows t cases. Every case starts with a positive integer n(0
/*求每一道工序的做之前的等待时间,和完成时间,比较时间(这道工序做之前的和时间前面一道工序的时间大小,前面一道工序时间大输出no)*/
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
int main(int argc, char *argv[])
{
int maxx,T,machine,map[509][509],inDegree[509],times[2][509],parts,ida,ids,t,idNeed,sums;
cin >> T;
while (T--) {
memset(map, 0, sizeof(map));
memset(inDegree, 0, sizeof(inDegree));
memset(times, 0, sizeof(times)); //初始化
cin >> machine;
maxx = 0;
for (int i = 1; i <= machine; i++) {
cin >> parts;
sums = 0;
for (int j = 1; j <= parts; j++) {
cin >> ida >> t >> ids;
maxx = max(maxx, ida);
times[0][ida] = sums;
sums += t;
times[1][ida] = sums;
for (int k = 1; k <= ids; k++) {
cin >> idNeed;
if (!map[idNeed][ida]) {
inDegree[ida]++;
map[idNeed][ida] = 1;
}
}
}
}
for (int i = 1; i <= maxx; i++) {
for (int j = 1; j <= maxx; j++) {
if (!inDegree[j]) {
inDegree[j]--;
for (int k = 1; k <= maxx; k++) {
if (map[j][k]) {
inDegree[k]--;
if(times[1][j] > times[0][k]) //时间比较这一道和前一道
{
cout << "No" << endl;
goto rFalse;
}
}
}
}
}
}
cout << "Yes" << endl;
rFalse:;
}
return 0;
}