My solution to the problem barely passed after many optimizations.... This problem mainly asks to calculate a functions value over a range of array and give output. My solutions offline query method.(MO's algorithm) Can anyone suggest any improvements !!
Problem : http://mirror.codeforces.com/problemset/problem/86/D
My Solution's Link : https://pastebin.com/Gcuxet5h
Thank You !
(PS : any other ways to do the problem are also welcomed :D )