Sort 22 Discussions, By:
Please Login in order to post a comment
i thought this could help you
This was really helpfull.Thanks man!!
You made it too easy. I already started learning Dijkstra algorithm just to solve this problem :)
I'm new to this. Is there a way to find out what the tests inputs are? I would love to know where my code stumbled.
if u will run your program and it will successfully submitted then you will get test input and check your program.....if your code is perfect then it will pass the test ......otherwise check your program by test input putting inside one by one!!!!
A very nice problem to do after Euler 67.
Yep. This is basically problem 67 rotated counterclockwise by 45 degrees
Nice question to brush up your basic skills on dp !!
yes my friend
Why am i getting RUN TIME ERROR in all testcases after TC2.I think my code is perfact I have done it with memoization.If anyone have the reason please answer me..
EDITED: I noticed that it fails when N crosses exactly 500.
Wrong answers for some test cases for using integer array. Use long array to avoid this.
Easy DP, no Dijkstra or advanced math necessary.
I dont understand whats wrong with this code.
was too easy and tried many matrixes before submission; though went something wrong. only two tests passed!
using namespace std;
unsigned int N=1;
if(N>=1 && N<=100)
unsigned long long int Mat[N][N], sumMat[N][N], ans=0;
for(unsigned int r=0; r<N; ++r)
for(unsigned int c=0; c<N; ++c)
else if(c==0 && r!=0)
to guarantee the lowest path, we need to run every possible combination. How can I optimize it? is gradient descent ok?
n = int(input())
ar = 
ar2 = 
for a in range(n):
ar.append([int(x) for x in input().split()])
ar2.append([0 for x in range(5)])
for i in range(1,n):
for i in range(1,n):
for j in range(1,n):
what u did IS THE most optimal algo..
using dijkstra's here is stupid coz it's
1.O(E+Vlog(V))..(using fibo heap)
2.O((E+V)log(V))..(using binary heap)
But since this is a dense graph(complete graph infact), E=n(n-1)/2 (nc2) and V=n^2 which makes dijkstra even slower whereas ur algo runs in exact O(n^2)....XD
thanks! just saw the error. ii's not range(5)
is the minimum path is single or multiple