Submit solution
Points:
7 (partial)
Time limit:
1.0s
Java
1.5s
Memory limit:
256M
Author:
Problem type
Since Max is heading off to university, he needs to create a course schedule for
However, each course has
Can you tell Max the order to take his courses to satisfy the prerequisites?
Constraints
It is always possible to generate a course schedule that does not conflict (i.e., it is possible to take every course without missing a prerequisite).
Subtask 1 [40%]
Subtask 2 [60%]
No additional constraints.
Input Specification
The first line will contain an integer,
The next
Output Specification
Output any valid permutation of the
Sample Input
Copy
5
0
0
3 1 2 5
3 1 2 3
1 2
Sample Output
Copy
1 2 5 3 4
Comments