|Author:||StdAlg||Time limit:||1 sec|
|Input file:||input.txt||Memory limit:||16 Mb|
You are to write a program that performs a topological sorting of a directed graph. Graph contains N vertices, numbered with integers from 1 to N, and M edges.
In other words, given a partial order on numbers from 1 to N, your program must produce some linear order on these numbers which does not conflict with the given partial order.
These pairs may also be considered comparisons where the first number precedes the second one.
Output file must contain a permutation of integers from 1 to N — numbers of vertices sorted in topological order. (That is, representing a linear order.) If ordering is not possible, output file must contain a single number − 1.
|No.||Input file (
||Output file (|