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?
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.
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