-->
当前位置:首页 > 题库

PROGRAMMING:Rationality of task scheduling

Luz5年前 (2021-05-10)题库417
Suppose an engineering project is composed of a group of subtasks, some of which can be executed in parallel, and some of which can only be executed after other subtasks are completed“ "Task scheduling" includes a set of subtasks and a set of subtasks on which each subtask can execute.
For example, the completion of all courses and graduation design of a major can be regarded as a project to be completed by an undergraduate, and each course can be regarded as a subtask. Some courses can be offered at the same time, such as English and C programming, they do not have to take which course first; Some courses can't be offered at the same time, because they are dependent on each other. For example, C programming and data structure should be studied first.
However, it should be noted that for a group of subtasks, not any task scheduling is a feasible solution. For example, in the scheme, "subtask a depends on subtask B, subtask B depends on subtask C, and subtask C depends on subtask a", then none of the three tasks can be executed first, which is an infeasible scheme. Your job now is to write a program to determine whether any given task schedule is feasible.
###Input format:
Input Description: input the first line to give the number of subtasks $$n $$($$Le 100 $$), and the subtasks are numbered by 1 ~ $$n $$. Next, $$n $$line, each line gives a dependency set of subtasks: first, give the number of subtasks in the dependency set, $$k $$, and then give the number of subtasks, $$k $$, separated by spaces.
###Output format:
If the scheme is feasible, output 1, otherwise output 0.
###Input sample 1:
```in
twelve
0
0
2 1 2
0
1 4
1 5
2 3 6
1 3
2 7 8
1 7
1 10
1 7
```
###Output sample 1:
```out
one
```
###Input sample 2:
```
five
1 4
2 1 4
2 2 5
1 3
0
```
###Output sample 2:
```
0
```






answer:If there is no answer, please comment