|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||1024 MB||40||16||16||42.105%|
A network of hyperspace highways is built in the galaxy. Each of the highways is a one-directional corridor which connects two planets. Galactic government wants to find a planet on which a police station will be built.
In order for the police to protect the whole galaxy, it must be possible to travel from the police station to every planet in the galaxy using the hyperspace highways network.
It is not necessary that the police can return back to the police station from any planet using the hyperspace highways. The police needs not to hurry on the way back, and so they can use slower ways than highways.
The government does not know how to deal with finding the suitable planet for the police station; therefore, they ask for your help
You are given the network of one-directional hyperspace highways. Find all planets from which it is possible to reach all other planets in the galaxy using some sequence of highways.
The first line of the input contains two integers $N$ a $M$: the number of planets and the number of highways.
Then, $M$ more lines follow. Each contains two integers $A_i$ and $B_i$: the numbers of planets connected by $i$-th highway. Each of the highways is one-directional and can only be used to travel from the planet $A_i$ to the planet $B_i$.
Output two lines. The first line should contain the total number of planets which are suitable for the police station. The second line should contain a space-separated list of these planets in ascending order.
5 6 1 3 1 4 4 2 2 1 2 5 5 4
4 1 2 4 5
3 2 1 3 2 3