RMQ Overkill |
For each case : First line, an integer N ( 1N10000), the size of the array. Second line, a string of N characters where i-th character denotes the i-th element of the sequence.
Output Explanation
First case: all possible queries and there results are, (0, 0) = > 1, (0, 1) = > 1, (0, 2) = > 1, (1, 1) = > 4, (1, 2) = > 3, (2, 2) = > 3. So, R = 1 + 1 + 1 + 4 + 3 + 3 = 13.
Second case: all possible queries and there results are, (0, 0) = > 4, (0, 1) = > 1, (0, 2) = > 1, (1, 1) = > 1, (1, 2) = > 1, (2, 2) = > 3. So, R = 11.
Third case: all possible queries and there results are, (0, 0) = > 1, (0, 1) = > 1, (0, 2) = > 1, (1, 1) = > 2, (1, 2) = > 1, (2, 2) = > 1. So, R = 7.
3 143 3 413 3 121
13 11 7
Problem Setter: Pratyai Mazumder
Alternate Solution: Mohammad Hafiz Uddin