maybe a cornor case to help.
Послано
hliu20 16 май 2013 14:18
Think about this case If you use DP
2 2
1 1
0 0
when considering the elem 0 at [1, 0] , you can find the way from [0, 1] -> [1, 0] and [0, 1] -> [1, 1] -> [1, 0] have the same sum(both are 1), how to handle this situation ?
I handle this by giving the way from `ABOVE` higher priority, or else when printing the path to the answer, you wil get [1, 0] <- [1, 1] <- [1, 0] <- [1, 1] ....... which is WA.
and another thing to notice is you may need long long to hold.
hope it helps :)