Can someone please help me to figure out why my code is getting TLE?
I think my code’s time complexity is O(T*(M*M)), I am sorting the query elements and then using previously computed values to compute value for new query. Overall i am visiting each element in the matrix atmost thrice.
Link to my submission : - https://www.codechef.com/viewsolution/32314206