Problem Link :
sol_1 - Submission (42310386) for Avoiding visited networked paths | HackerEarth
sol_2 - Submission (42310330) for Avoiding visited networked paths | HackerEarth
sol_1 gave MLE in some of the test cases , whereas on using arrays instead of vectors, it gets accepted…(sol_2)
And on what basis should we make a choice between vectors or arrays for a problem…
But i made all the values dp[i][j] = -1 in array based solution also…
whereas in vector also , the same thing happens during declaration
vector< int > v(n,-1);
please tell me where am I going wrong?
You have declared 9nm vectors, and each vector uses 24 bytes of data on top of the memory it keeps. So the size of the vector is 400 MB.
I may have made a calculation error on the last post.
Edit : Just to be sure, I changed the order in which the vectors are declared to create only 27 vectors and got AC
That was really helpful.