9 人解决,20 人已尝试。
10 份提交通过,共有 44 份提交。
7.2 EMB 奖励。
单点时限: 3.0 sec
内存限制: 256 MB
You are a president of the corporation. One day, your employees caused the strike. They required more vacation. So you considered how to finish the work in minimum time and finally you dicided to write a program to calculate a minimum time to finish the work. The work consists from a lot of tasks. And the order of execution which must be kept exists among some tasks. You can assume that each task takes the same one unit time.
Input consists from multiple test cases. The first line of each test case contains two positive integers n less than 100 and r less than n2 separated by a single space. The n indicates the number of task in this work. The r indicates the number of relationship between two tasks. Following r lines contains two positive integers a and b less than or equal to n separated by a single space. This means a-th task must be finished before b-th task starts. Input is terminated by EOF.
For each test case, you should output a minimum time to finish the all tasks. If the work cannot finish, output “Impossible”. You should output a blank line between two test cases.
4 3 1 2 1 3 2 4 2 2 1 2 2 1
3 Impossible
9 人解决,20 人已尝试。
10 份提交通过,共有 44 份提交。
7.2 EMB 奖励。