Editorial for CCC '19 S5 - Triangle: The Data Structure

Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.

Submitting an official solution before solving the problem yourself is a bannable offence.

Right-align the 2D array. If we iterate over the 2D array in increasing size order of minor diagonal, insert those values into a 2D max-BIT, we can query the bottom-right corner of a triangle the moment we have inserted all of the values in the given triangle into the 2D BIT, assuming the default values are otherwise zero. This approach is \mathcal{O}(N^2 \log^2 N).

Edit from another editorial author: You can solve it in \mathcal{O}(N^2 \log N).


There are no comments at the moment.