I've been stuck with this problem for a couple of days. I came up with a strange 3-dimensional dp and the constraints actually allowed it, so I coded it and ran into wrong answers (nothing new)
Now I'm noticing that if the given inputs are all their maximum (250), it will be equivalent to a 250 * 250 board and the answer is 250! which cannot be stored. But the problem statement doesn't mention any guarantee, nor does it say that I should return the answer modulo 1e9 + 7 or something like that.
I'm getting wrong answer on test 15 (it could be a problem with my solution as well) but just asking, what's up with this?