[Community Puzzle] Target Firing

I tried to use DFS to solve the problem but it seemed to have a timeout for The Swarm and Close Call cases. Is there a better algorithm?