report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Distance to polygon - MarisaOJ: Marisa Online Judge

Distance to polygon

Time limit: 1000 ms
Memory limit: 256 MB
Given a convex polygon of $n$ vertices and a point $A(x, y)$ locating outside of the polygon. Find the shortest distance from $A$ to the polygon. ### Input - The first lines contains three integer $n,x,y$. - The next $n$ lines, each line contains two integers $x, y$, which describes a vertex of the polygon. The points are listed in clockwise order. ### Output - Print the shorest distance. Your answer will be considered correct if its absolute or relative error does not exceed $10^{-3}$. In other words, your answer, $x$, will be compared to the correct answer, $y$. If $|x-y| < 10^{-3}$, then your answer will be considered correct. ### Constraints - $ 1 \le n \le 1000$. - $-10^9 \le x, y \le 10^9$. ### Example Input: ``` 3 0 0 2 0 0 2 2 2 ``` Output: ``` 1.4142 ```
Geometry
Three points
Line segment intersection
Line intersection
Quadrilateral classification
Point location
Triangle classification
Polygon area
Distance to polygon
Convex hull
Perpendicular pairs
Maximum quadrilateral
Catching butterflies
Topic
Geometry
Rating 1400
Solution (0) Solution