usernameson's blog

By usernameson, history, 19 months ago, In English

Assume you have problem where there's tree with 100000 vertices and you have to answer 100000 queries of the form (x,y) meaning root the tree at x and then calculate some property for the subtree rooted at y. Assume the problem is easy to solve with tree dp for a fixed root but not obvious how to use tree rerooting dp. You could pick 100 roots and random then pre-calculate the answers and hope for each query in at least one of these rooted trees x is not in the subtree rooted at y. How would you create a test case that has a high probability to break such an approach?

Tags tree, dp
  • Vote: I like it
  • +5
  • Vote: I do not like it

»
19 months ago, hide # |
 
Vote: I like it +21 Vote: I do not like it

Maybe query all leaves as x and adjacent node as y?