Editorial for Weapons of mass distraction

Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Author: Tommoa

Editorialist: Tommoa

This was another relatively easy problem, given that you can reason your way around a bit of geometry!

There's more than enough time given our restrictions to aim for a \(O(n^2)\) solution. If we read all of the bomb positions and radii into a vector, we can simply iterate through each pair and check whether the distance between the pairs is \(\leq 0\). If it is, we can have two possibilities:

  • The final bomb has been placed and causes an explosion.
  • Another bomb has been placed and the error detected. In the first case, we need to mark that we have an error and continue on, after all we could have a collision between the first and the last placed bombs, but the second and third bombs may also collide!

In the second case, we can just print safely stopped collision and return.


There are no comments at the moment.