C: Safe Houses

https://open.kattis.com/problems/safehouses

  • For every house-spy pair with coordinates (xh,yh)(x_h,y_h)and (xs,ys)(x_s,y_s), calculate the distance as xhxs+yhys|x_h-x_s| + |y_h-y_s|. All pairwise distances can be computed this way in quadratic time.

  • Now, for each spy, compute the distance to the closest house. Report the minimum such value.

Last updated