In yesterday's contest, my solution for problem C received WA on test 3. I went crazy trying to find a mistake in the logic.
Turns out I hadn't initialized my border
variable to -1 (in case when a border doesn't exist) and thus it contained some garbage value and was giving wrong output.
Sadge, guess I learnt something.