#P5195. DZY Loves Topological Sorting

DZY Loves Topological Sorting

Problem Description

A topological sort or topological ordering of a directed graph is a linear ordering of its vertices such that for every directed edge $(u\rightarrow v)$ from vertex $u$ to vertex $v$, $u$ comes before $v$ in the ordering.
Now, DZY has a directed acyclic graph(DAG). You should find the lexicographically largest topological ordering after erasing at most $k$ edges from the graph.

Input

The input consists several test cases. ($TestCase\leq 5$)
The first line, three integers $n,m,k(1\leq n,m\leq 10^5, 0\leq k\leq m)$.
Each of the next $m$ lines has two integers: $u,v(u\not= v, 1\leq u,v\leq n)$, representing a direct edge$(u\rightarrow v)$.

Output

For each test case, output the lexicographically largest topological ordering.

5 5 2 1 2 4 5 2 4 3 4 2 3 3 2 0 1 2 1 3
5 3 1 2 4 1 3 2

Hint

Case 1.
Erase the edge (2->3),(4->5).
And the lexicographically largest topological ordering is (5,3,1,2,4).