| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 128 MB | 116 | 72 | 59 | 62.105% |
There is always a list of things to be done!
Here is a list for you left just this morning by your parental figure.
(It is nice that your parental figure makes sure you watch television, and not just use the internet all day long.)
As well, your parental figure has given you constraints on these tasks:
Your “to do” list (above) can now be abbreviated to:
1,7 1,4 2,1 3,4 3,5
where x, y indicates that the task numbered x should be done before the task numbered y.
Unfortunately, during the day additional instructions are emailed to you by your parental figure. Write a program to use your original “to do” list and the additional instructions to output a list of your jobs in the order you must do them, or alternately, if you cannot complete them, you should output that there is no way to complete these tasks, and you are just going to go to bed.
You will be given pairs of numbers, one number per line, to represent the additional instructions to be included with your original “to do” list given above. The data terminates with the input pair 0 and 0. You can assume that there will be at most 10 additional constraints.
You should output a list of tasks in the order that they should be performed, or an error message saying that the tasks cannot be completed. If there are multiple orders in which the tasks may be completed, the following tie-breaking rule must be used:
If there is a set of tasks which may be performed at the same time during the process, the smallest numbered task should be performed first.
6 2 5 4 0 0
3 5 6 2 1 4 7
7 2 4 5 0 0
Cannot complete these tasks. Going to bed.