Getting TLE in Rectangle Cutting(CSES PROBLEM)

I get stuck. Don’t know why I am getting TLE in two test cases.

Problem link:CSES - Rectangle Cutting
Solution link:https://cses.fi/paste/5ae62c7db2d5d64029b7d0/

Use for loop fo(i,m/2+1) and fo(i,n/2+1) because the each pair of i and m-i are repeated twice in dp states. Similarly for n.

1 Like