RECTQUER - Editorial

http://discuss.codechef.com/questions/32038/prefix-sumhelp

^^
please tell how to solve with binary search?

You may look at the figure. It is based on inclusion-exclusion principle actually. But it is straightforward in the picture.

Nope, here S[][], is a prefix matrix of binary matrix for a given number.d. Please read the editorial step by step. We first divide the original problem into D parts (D is the number of different numbers in the original matrix, at most 10).

Has the time limit been changed for this? My submission failed at 2 seconds, but I see that others have passed at 2+ and even 4+ seconds.