C: Safe Houses
https://open.kattis.com/problems/safehouses
For every house-spy pair with coordinates and , calculate the distance as . All pairwise distances can be computed this way in quadratic time.
Note that if the size of the grid is , there are at most houses and spies. So, computing all pairwise distances can be done in , which is fast enough to fit in the time limit.
Now, for each spy, compute the distance to the closest house. Report the minimum such value.
Last updated