cpinitiative / usaco-guide

A free collection of curated, high-quality resources to take you from Bronze to Platinum and beyond.
https://usaco.guide
Other
1.6k stars 476 forks source link

CSES - New Roads Queries Solution #4636

Open Oz121 opened 1 month ago

Oz121 commented 1 month ago

For this problem, the solution given (https://usaco.guide/problems/cses-2101-new-roads-queries/solution) uses Platinum topics.

There's a more elementary solution with parallel binary search here: https://duoblogger.github.io/assets/pdf/memonvyftw/guide-t-cp.pdf (section 15.5.3). Also, the top user solution uses parallel binary search.

bqi343 commented 1 month ago

another way (though not simpler) is to convert the tree into a line, then it reduces to RMQ queries which can be answered in $O(1)$ time each.

ref: https://codeforces.com/blog/entry/71568?#comment-559304