https://www.codechef.com/viewsolution/21308966 my code has same time complexity (O(nm(n+m))) as in editorial but still getting TLE. Can please anyone explain why
Your complexity analysis is correct. You are getting tle due to large constant factor involved. Your AC Soln. I made arrays global and now it barely passes.
Upd - lol submitting same soln again gives tle, again tle, and then AC. xD