KNGHTMOV - Editorial

Try this case: (your code gives fpe)

2 0 0

1 0 -1 0

Another case: (solution is 1 instead of -1)

3 3 3

3 3 -1 -1

-1 -1 2 2 6 6

Where are you doing the cycle detection mentioned in the editorial?

Thanks a lot for the explanation ,now I get it :slight_smile: .The editorial mentions nothing of handling this case.

I will add it to the Editorial :slight_smile: Thanks!

Please explain / give some reference for Bellman Ford + Dynamic Programming.

my solution id is
i have done it in i different way and i know that i have missed some cases just want to know which one i meissed

please help

Will the links to the solution by tester and setter ever be updated ?

1 Like

Don’t think they exist. :stuck_out_tongue:

1 Like

@Sumudu Why can’t we do the same thing in case I.

The search space then would be 1000 X 10000 which should be acceptable. We’ll perform a dp (as you mentioned for case II) by traversing the DAG to count the number of ways and avoid those vertices from which the final destinal X,Y cannot be reached. In case a cycle is detected, the answer will be -1.

Why use Gaussian elimination ?