The key to my solution was the recursive traversal (traverse_graph) of a directed graph. The representation of the graph is a dictionary of the monks as keys and a list of the following monks as values.
Because running on the large input file raised a runtime error of maximum recursion depth exceeded, I used a this little hack:
sys.setrecursionlimit(10000)
.UPDATE: Here are the solutions of the contestants.
No comments:
Post a Comment