At least for this program, a pseudocode is very helpfull. I was making a pseudo-code to post here because it's easyer for others to understand. Suddenly I perceived my mistake, by reading what I wrote.
I was solving it by DP in this manner:
All cells start with length 0. Cells out of area have -1 of tallness, weight 0.
LongestRun = 0
For weight W = 0 to 100 do:
--For any cell C (inside the area) with height W do:
----For each adjacent cell C2 do:
------If LengthOf(C2) + 1 > LengthOf(C), then do:
--------LengthOf(C) = LengthOf(C2) + 1
------end if
----end do
----If LengthOf(C) > LongestRun then LongestRun = LengthOf(C)
--end do
end do
I assumed the longest run would always end in an border cell of that area, so one more unit of length would be counted as a dropping to outside the area. But not I realised the longest run can finish inside the area. My new pseudo code is:
All cells start with length 1.
LongestRun = 0
For weight W = 0 to 100 do:
--For any cell C (inside the area) with height W do:
----For each adjacent cell C2 (inside the area) do:
------If LengthOf(C2) + 1 > LengthOf(C), then do:
--------LengthOf(C) = LengthOf(C2) + 1
------end if
----end do
----If LengthOf(C) > LongestRun then LongestRun = LengthOf(C)
--end do
end do
And here are some critical inputs I made:
4
me 0 0
me2 1 1
0
you 3 3
0 0 0
0 0 0
0 0 1
center 3 3
1 1 1
1 0 1
1 1 1
Sample output for it:
me: 0
me2: 1
you: 2
center: 2
But I still did NOT get accepted
Any problems with my critical input answers or with my assumptions?
By the way, ttwu.. I also can't see why your second code worked but your first one didn't. Both seem to backtrack well the Len value, but the 2nd solution is cleaner.
I solve 4 problems per day, then I expend 4 days stuck in a single problem. But I think I'm doing well... ID 37180