We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Kingdom Division
Kingdom Division
Sort by
recency
|
64 Discussions
|
Please Login in order to post a comment
the test case 1 gives me a simple data Input (stdin):
How is that possible to divide it six ways? I count only 4 because it is a particular case of the case in example, is not it?
Recursive solution doesn't work on Python because of the maximum recursion limit (e.g. Test 11 has a tree with 72000 depth). sys.setrecursionlimit(100000) doesn't work because Python still crashes at ~2670 level of recursion. What works: using Kahn's algorithm to iteratively go from the leaves to the root. New style Prescription wooden glasses
took me AGES to debug
O(n)
Why this is medium difficulty?