APIO 2012 Guard - Why does this pass the TL?

I’ve recently been trying to solve APIO 2012 Guard. I was going for the 50-point O(N^2) subtask using DP + a DFS to check for “articulation points”. When I submitted the code though, it passed all test cases using 0.1s max. Here’s my code with my approach. Are the test cases just weak, or is my solution somehow actually linear?