Can someone please explain why this solution is getting TLE?
\nq=[]\nheapq.heapify(q)\nheapq.heappush(q,[0,0,0,True])\nm=len(moveTime)\nn=len(moveTime[0])\nans=[[float(\'inf\') for i in range(n)] for j in range(m)]\nwhile
```\nq=[]\nheapq.heapify(q)\nheapq.heappush(q,[0,0,0,True])\nm=len(moveTime)\nn=len(moveTime[0])\nans=[[float(\'inf\') for i in range(n)] for j in range(m)]\nwhile(len(q)>0):\n    i,j,wt,pre=heapq.heappop(q)\n\n    ans[i][j]=min(ans[i][j],wt)\n    if i+1<m :\n        if pre==True:\n            tmp=max(0,moveTime[i+1][j]-wt)+1+wt\n            if tmp<ans[i+1][j]:\n                heapq.heappush(q,[i+1,j,tmp,False])\n\n        else:\n            tmp=max(0,moveTime[i+1][j]-wt)+2+wt\n            if tmp<ans[i+1][j]:\n                heapq.heappush(q,[i+1,j,tmp,True])\n    if j+1<n :\n        if pre==True:\n            tmp=max(0,moveTime[i][j+1]-wt)+1+wt\n            if tmp<ans[i][j+1]:\n                heapq.heappush(q,[i,j+1,tmp,False])\n\n        else:\n            tmp=max(0,moveTime[i][j+1]-wt)+2+wt\n            if tmp<ans[i][j+1]:\n                heapq.heappush(q,[i,j+1,tmp,True])\n\n    if i-1>=0:\n        if pre==True:\n            tmp=max(0,moveTime[i-1][j]-wt)+1+wt\n            if tmp<ans[i-1][j]:\n                heapq.heappush(q,[i-1,j,tmp,False])\n\n        else:\n            tmp=max(0,moveTime[i-1][j]-wt)+2+wt\n            if tmp<ans[i-1][j]:\n                heapq.heappush(q,[i-1,j,tmp,True])\n\n    if j-1>=0 :\n        if pre==True:\n            tmp=max(0,moveTime[i][j-1]-wt)+1+wt\n            if tmp<ans[i][j-1]:\n                heapq.heappush(q,[i,j-1,tmp,False])\n\n        else:\n            tmp=max(0,moveTime[i][j-1]-wt)+2+wt\n            if tmp<ans[i][j-1]:\n                heapq.heappush(q,[i,j-1,tmp,True])\nreturn ans[-1][-1]\n```\n\nTC - \n```\n[[0,88,52,40,24,11,82,54,52,5,24,77,58,37,37,54,24,97,54,79],[81,92,0,9,63,19,98,28,93,38,71,47,29,30,41,47,17,81,33,46],[48,7,84,50,85,80,32,99,74,68,42,88,59,87,23,80,8,42,68,31],[40,45,86,84,69,19,85,52,0,41,8,22,5,56,16,23,9,16,56,50],[2,72,9,73,84,54,3,44,39,14,94,44,5,24,50,73,27,9,90,70],[87,0,16,24,45,97,51,99,25,54,43,75,21,71,81,66,0,81,59,45],[52,51,92,68,88,100,27,52,43,1,100,83,38,51,13,11,30,39,52,51],[51,65,30,69,29,13,1,58,1,73,87,80,71,11,16,64,38,13,84,34],[10,21,83,24,49,36,23,15,91,16,77,98,79,85,48,15,18,89,34,8],[20,34,27,43,39,91,94,19,92,71,22,42,76,58,5,91,61,64,59,75],[57,49,9,1,34,81,99,16,28,61,88,3,27,45,56,91,53,67,33,0]]\n\n```
[]