The agent must kill all the terrorists before $k$ 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 ($r*6$) 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 $a_i$ is denoted by $0$, the agent cannot move further. So, after ensuring Srikant has enough bullets to kill all the terrorists, run a $dfs$ and check is it possible to go all the cells where terrorists are stayed. If it is possible, calculate the required time. Complexity $O(n)$ or $O(nlogn)$ depending on your implementation.

80% Solution Ratio

faria_efaEarliest,

prodip_bsmrstuFastest, 0.1s

prodip_bsmrstuLightest, 12 MB

antihashShortest, 824B

Toph uses cookies. By continuing you agree to our Cookie Policy.