Toxic Barrier
Time limit1sMemory limit128 MB
Find the convex hull of N points and add a buffer of distance L around it, giving the minimum closed barrier length rounded to the nearest integer.
- Level
Medium6 of 10
- Topics
- Geometry, Sorting, Math, Implementation
- Solved
- No attempts yet
Problem

Seongjun, king of the Chemical Empire, decided to build his nation's pride — a chemical barrier — to finally be free from the repeated invasions of neighboring countries. The barrier releases a toxin harmful to any creature that comes near, so that no other nation dares to approach.
However, the barrier is difficult to construct, so it must be made as short as possible. It can also harm the king's own people, so it must always stay at a distance of at least from every building in the country.
Given the coordinates of the country's buildings, find the minimum length of a barrier that encloses all of the buildings at once while keeping a distance of at least from every building.
Input
The first line contains the number of buildings and the distance . (, ; and are integers.)
Each of the next lines contains the integer coordinates and of a building. () All building coordinates are distinct, and each building is small enough to be treated as a single point. The barrier must not cross itself and must not be broken.
Output
Print, on the first line, the minimum length of the barrier that encloses all buildings, rounded to the nearest integer.