In worst case there are a total of 2*50000 nos (including updates) that will be needing 10^5 * 2^6 * log2(50000) = 99901699 nodes that is well within the Memory Limit.
We have solved the problem in O( 2^6 * Q * log2(N) ) time and O( 9*10^7 ) memory
In worst case there are a total of 2*50000 nos (including updates) that will be needing 10^5 * 2^6 * log2(50000) = 99901699 nodes that is well within the Memory Limit.
We have solved the problem in O( 2^6 * Q * log2(N) ) time and O( 9*10^7 ) memory
how to find F(x,L,R) in O(logN) time by querying over ordered set corresponding to x ? If I am using ordered_map , I can get iterator corresponding to L and R in O(logN) . But getting their difference will take linear time .
nice approach sir +1