
We first consider the local structure of the farm after the earth quake.
Let v be a field that's undamaged but cannot return to the barn. Let u be another field such that there is a path between u and v. Then if u is undamaged and cows can return to the barn from it, then walking along the path from v to u then taking that path returns the cows to the barn as well. Therefore, u must be either damaged or cannot return to the barn.
One interesting observation is that for all the vertices that are not among the ones listed that are unreachable from the barn, there is no additional penalty of listing them as damaged. So we have a minimum set of 'damaged' fields. Marking these as damaged then doing a flood fill from the barn gives the minimum number of fields that cannot reach the barn.
Under this algorithm, any field marked unreachable must satisfy that all paths from the barn to it must go through a neighbor of the reported fields. Since all of those fields cannot reach the barn via undamaged fields, the unreachibility of the marked fields follows.