10913 - Walking on a Grid
Posted: Sat Sep 24, 2005 5:13 am
dp? 

My time complexity is O(kn^2), too. And the memory complexity is O(kn).Anonymous wrote:Are you sure about o(k * n^2) ?wook wrote:yes, it's DP
time complexity is about o(k * n^2)
My algo takes o(k * n^3). And work fast enough.
It would have been more significiant if n would be much bigger than 75.kp wrote:Thx, I optimized my algo. Now it's O(k * n^2) too.
However running time didn't improved much.
I'm lazy to generate any inputsLarry wrote:Can someone post some example cases? Thanks!
I used following DP-algorithm:ayon wrote:hi,
i cannot make a way to use DP in this problem. if you anyone describe how to implement DP here, i will be greatly helped. btw, can this problem be solved within time limit using dfs?
thanks in advance...
Try this input:L I M O N wrote:Someone pls send some critical data, i m getting WA again and again. i use DP.
Thx in Advace.
L I M O N
Code: Select all
1 0
1
1 0
-1
1 1
-1
3 0
1 1 1
1 1 1
1 1 1
4 0
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
4 1
1 -1 1 1
-1 1 1 1
10 -1 5 1
1 1 1 1
3 5
-1 -1 -1
-1 -1 -1
-1 -1 -1
3 4
-1 -1 -1
-1 -1 -1
-1 -1 -1
5 2
2 -1 10 3 13
5 -4 3 -2 1
-100 2 3 43 17
24 92 40 14 40
100 100 -1 -1 1
0 0
Code: Select all
Case 1: 1
Case 2: impossible
Case 3: -1
Case 4: 9
Case 5: 13
Case 6: 14
Case 7: -5
Case 8: impossible
Case 9: 280