Editorial for 2-Dimensional Range Minimum Query


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.

Author: wleung_bvg

This editorial will not go through specific implementation details.

Let Q be the number of queries.

Subtask 1

Check all elements in the submatrix.

Time Complexity: O(QN2)
Memory Complexity: O(N2)

Subtask 2

Build N segment trees.

Time Complexity: O(N2+QNlogN)
Memory Complexity: O(N2)

Subtask 2 Alternative Solution

Build N sparse tables.

Time Complexity: O(N2logN+QN)
Memory Complexity: O(N2logN)

Subtask 3

Build a 2-dimensional segment tree.

Time Complexity: O(N2+Qlog2N)
Memory Complexity: O(N2)

Subtask 4

Build a 2-dimensional sparse table.

Time Complexity: O(N2log2N+Q)
Memory Complexity: O(N2log2N)

Fun Solution

There are ways to abuse the randomness of the data.


Comments

There are no comments at the moment.