Chef And Cake - WA

For the May 15 long challenge problem CHEFCK, I created a sparse matrix to create a cache and then process the queries in O(1) time. But it gives me wrong answer for this code. If I try to change from unsigned int to unsigned long long int, it gives Runtime Error. Can anyone help me find what is wrong?

The Sparse Matrix algorithm that I have used is the same logic I used for FRMQ (for which I got AC). FRMQ Sparse Table Algo.

One problem with your code - Do not use mod with sum. May be other also .

Instead of converting sparse table to unsigned long long int you may change a little bit in your algorithm i.e. in the sparse table just note the positions of the minimum elements of sub range not the values as given in topcoder tutorial which is memory efficient.

I tried doing it :


(http://www.codechef.com/viewsolution/7027459). It still gives me WA.