Hello everyone ! I am trying to solve this problem.I didn't understand the editorial properly. Please help me to understand the binary raise used in the editorial. Because i am new to this concept, provide me some tutorial to learn it.Thanks :)
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
Hello everyone ! I am trying to solve this problem.I didn't understand the editorial properly. Please help me to understand the binary raise used in the editorial. Because i am new to this concept, provide me some tutorial to learn it.Thanks :)
Name |
---|
Looks like it refers to the Sparse Table structure complementary to the LCA algorithm. The author may have used this name because the Sparse Table indexes are equivalent to powers of two ("binary raises")
I believe binary raise refers to "skips" of power of two used in the LCA algorithm. For LCA, we store for each node, the nodes at distances 1, 2, 4, 8... and so on, going to the root. That way we'll be able to answer queries in logarithmic time. I think the editorial is pretty clear to understand the rest of the problem (dealing with different cases). The pictures are very helpful.
Refer to my code if it helps -> C++ Code