F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

DZY Loves Topological Sorting

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 1331    Accepted Submission(s): 441


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.
 

Sample Input
5 5 2 1 2 4 5 2 4 3 4 2 3 3 2 0 1 2 1 3
 

Sample Output
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).
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-28 01:01:05, Gzip enabled