The agent must kill all the terrorists before minutes. And to kill all the terrorists, the total number of bullets required to kill all the terrorists must be less than or equal to the number of bullets () the agent has in his possession. The path from each cell leads the agent to a certain cell. The paths/roads are one way. Two/more different cells can have paths that lead to one cell. The agent must not go back to a cell that is already visited. Because if he does, he will fall into an infinite loop. If is denoted by , the agent cannot move further. So, after ensuring Srikant has enough bullets to kill all the terrorists, run a and check is it possible to go all the cells where terrorists are stayed. If it is possible, calculate the required time. Complexity or depending on your implementation.