so it locks like :
and the the fences should (i think) be like :
so my answer is 5 ... but the Accepted code output is 3 !
i can't understand how to but only 3 fences to prevent the snakes communicate with each other . can any one explain this problem to me ?
thanks in advance .
UPD: the optimal solution for the above sample :