DEFKIN problem spoj

I’m unable to pass all the test cases of sopj, which case am I missing??

@sounakume,
here
is a better way to do it, also just compare it with your code you will know your bug.

I dont understand how is your approach works mine doesn’t , i applied the same logic just coded it in a different matter, I couldn’t find any bug in mine, please explain

@sounakume,
The answer for n==0 case would be (w-1)*(h-1) or w*h…??

yes it should be w*h, i did submit like that, but it did not work

@sounakume,
You are doing the similar -1 problem in your code again. Find that out. That is why I say, try to implement it the way I did, you will understand where your mistake was. Even my code was not accepted when I did it like you are doing.