Comments

You can also implement SPLIT and MERGE in the BST. You then split the tree twice to isolate the nodes in the range [l, r]. Keep in mind SPLIT takes log n time (assuming the tree is balanced). Then you just read the aggregate statistic (sum in this case) from the root of this new tree. Then you can merge them together in the end.

Well, if you used the standard TSP, the trick is to make a "fake" node with dist 0 to all other nodes. Then you can run TSP as normal.

Yeah but my recursion doesn't end when I hit a node with L=R; it ends when I hit a node that is completely contained within the query interval.

Well, a node is a leaf if the left (start) endpoint and the right (end) endpoint are the same number.

I use it in chrome with an extension called "TamperMonkey".

I just fixed a potential issue with invalid script header by adding two match URLS into the header.

I have been using a simple userscript for about 1.5 weeks. It redirects you to the corresponding contest site if you click a problemset link.

http://userscripts.org/scripts/show/155850 See if you like it

+1

Can anyone spare a small hint for Problem -- E?

That is very cool. Is computing the s[] array a common trick? Thanks!

Thanks for the detailed explanation!

Can anyone explain why the complexity for Time to Raid Cowavans (Div1-D) is O(P * sqrt(N))? I'm new to this complexity analysis stuff

On ifsmirnovCodeforces Round #121, 14 years ago
0

UPD: Never mind, just did a bunch of other problems with LCA, makes sense now. Thanks for the insight!

Hey, sorry I'm replying to a comment so late, but why is it f(p,  - 2)? Thanks

From looking at the code I think it is "Lazy Propagation". Search that up