2647Factory Pipelining

2647   Factory Pipelining

题目描述

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<n<=30), representing the machine number. And in each case, there follows n sets of data. In each set, the first line has a positive integer m(0<m<=30), representing the parts that are going to be processed on this machine, then follows m sets of data, every first line has 3 positive integers, id(the id that identifies the part, being unique in each case, numbered from 1), time(the time spent to process this part), p(the number of parts it needs), then follows p lines, each line has an integer idx, indicating the id of the parts that this part needed.

输出格式:

For each case, if the schedule table can be carried out strictly following the rules of pipelining, output “Yes”, else output ”No”.
输入样例 复制
2
3
3
1 1 0
2 3 0
3 5 1
4
3
4 3 0
5 3 2
1
7
6 1 1
5
4
7 2 0
8 3 0
9 2 1
2
10 1 0
2
2
1 1 0
2 3 1
3
2
3 2 0
4 2 1
1
输出样例 复制
Yes
No

说明

The black line between working procedure boxes represents order relationship. Sample 1 is shown below.

As shown in the picture, the order relationship represented by the black line that has been crossed breaks the rules of pipelining. So in case 2, the answer is “No”.


7
21
通过提交
时空限制1000ms/64mb
题目来源数据结构实验与竞赛训练
评测方式在线评测
题目类型
难        度