Hello, This is the problem link Problem - D - Codeforces.
I used DP bottom-up approach in one solution and top-down in other solution but top-down is giving TLE can anyone help me out why?
Bottom-Up approach Solution: Submission #114173603 - Codeforces
Top-Down approach Solution : Submission #114173758 - Codeforces
For the TLE version, you are passing
mindis by value instead of reference, which is likely slowing things down a lot.
Thanks Man!! It worked! Thanks a lot!!
If you’re online then please help in my submission of same problem. I don’t know why it is giving WA on test-5. Here’s my commented code I hope it would be easy to understand.
I have corrected some mistakes in your code have a look Submission #114179033 - Codeforces
Thanks for the reply. Upon inspection i found that my first code itself was correct the only culprit was my input for the vertical edges. I was taking the second input in wrong order. Upon changing that It worked