|
|
вернуться в форумNice problem! To solve it your needto use the topological sort on the graph (DAG). It can be done with DFS algorithm. Actually I just sorted twice(one ascending and another one descending) and got AC. Your(compiler) idea is interesting, but not clear to me. Can you tell me your idea in details plz? You can also make this via e-mail: akshinioi@yahoo.com Edited by author 27.04.2005 21:52 VladG is right. It's the topological sort problem. See Cormen, Leiserson, Rivest, Stein "Introduction to algorithms" -> Elementary algorithms for graphs -> Topological sort The idea doesn't seem to be so clear. |
|
|