Initially, I was using vectors and resizing it to create a 2D array. It led to MLE in all but 1 case.
I replaced it with a map to possibly reduce memory use in resizing but now I get MLE and TLE.
Getting MLE in all but 1 case
hello @varun.saxena
u are storing string corresponding to evry possible state .
that is why it is giving tle.
one more thing why r u declrementing y(i,e m ).
it will remain as it is.
if u place 1*m time horizonally then it will reduce n by 1.
otherwise if u place it vertically then it will reduce n by n-m .
dp(n)=dp(n-1)+dp(n-m)
this is the recurrence relation for this problem. and u can use 1d dp easily .
I understood your point and changed the code.
It is failing for some test cases, not able to figure out why.
check output format , i think the questions demans ans%mod in place of ans.
so do two things.
use long long in place of int
use mod property while performing arithmetic addition
(a+b)%mod=(a%mod+b%mod)%mod
Did that as well, still didn’t work out.
mistakes
a) this (^) operator computes xor but u were using it to compute power.
b) resize never chnage the existing values. only size of vector get changed .
try to execute these programs and observes there values.-> https://www.geeksforgeeks.org/vector-resize-c-stl/
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.