Here’s the question [DQUERY][1].
I’m using MO’s Algorithm and here’s my
[2]. Tried almost everything. fast i/o,print scanf,all other optimizations.
Any help please?
Thanks in advance. :)
[1]: http://www.spoj.com/problems/DQUERY/
[2]: http://ideone.com/b2ARA3
I think your solution is giving tle because of the compare function. Firstly, your 2nd return statement is wrong, as we just return on basis of “r” values and not on basis of “r/block_size” value. Second, we are doing the same calculation for “l/block_size” 4 times, where it can be done only 2 times using variable. (See my compare function). So the contant factor reduces in your code too. Hope this would do the job.