usaco-guide icon indicating copy to clipboard operation
usaco-guide copied to clipboard

Contact Form Submission - Suggestion (Centroid Decomposition)

Open maggieliu05 opened this issue 1 year ago • 4 comments

Someone submitted the contact form!

URL: https://usaco.guide/problems/cses-2081-fixed-length-paths-ii/solution Module: Centroid Decomposition Topic: Suggestion Message: The internal solution for CSES - Fixed-Length Paths II (the centroid decomp one), TLEs on cses judge

maggieliu05 avatar Dec 25 '23 11:12 maggieliu05

you're right. perhaps the judges have gotten slower or tests have been added to this problem. I would suggest removing the binary indexed tree from the solution to remove a log factor.

bqi343 avatar Dec 25 '23 16:12 bqi343

how is that possible, can you please explain (if there is a solution other than small-to-large merging using cd)

enfuego27826 avatar Jan 03 '24 05:01 enfuego27826

I'm not sure what you mean by small-to-large merging using cd. The centroid decomposition solution in the module doesn't use small-to-large merging.

The idea for speeding up the centroid decomposition solution is to use that the indices of each update / query change only by one between consecutive queries or updates. So each of them can be done in O(1) instead of O(log N) time.

Alternatively, you can do all updates in O(1), then do prefix sums, then do all queries in O(1).

bqi343 avatar Jan 03 '24 14:01 bqi343

okay sure, thanks

enfuego27826 avatar Jan 04 '24 13:01 enfuego27826