eolymp
bolt
Try our new interface for solving problems
Problems

Area Between Outer Hull and Inner Hull

Area Between Outer Hull and Inner Hull

Given a set \textbf{S} of \textbf{N} points on the plane, namely\textbf{ S = \{(x\[0\], y\[0\]), (x\[1\], y\[1\]), ..., (x\[N-1\], y\[N-1\])\}}, the \textit{outer hull} \textbf{Ho }of \textbf{S} is simply just the convex hull of \textbf{S}. It is a subset of points of \textbf{S} which when joined by line segments will form a convex polygon \textbf{P} of minimum area that includes all points of \textbf{S} inside \textbf{P} or on \textbf{P}. Points of \textbf{S} falling on \textbf{P} but are not corner vertices of \textbf{P} are not considered part of the convex hull. The \textit{inner hull} \textbf{Hi} of \textbf{S} is obtained by getting the convex hull of \textbf{S--Ho}. That is, remove from set \textbf{S} all points that belong to the outer hull \textbf{Ho}, to get the set \textbf{(S--Ho)}. Then compute the inner hull \textbf{Hi} as the convex hull of \textbf{(S--Ho)}. \includegraphics{https://static.e-olymp.com/content/fb/fba50093355eeed09781c310ce218aa3bb0fca9f.jpg} For example given the set \textbf{S} of \textbf{8} points \textbf{A(2.0, 5.0)}, \textbf{B(2.0, 4.0)}, \textbf{C(2.0, 2.0)}, \textbf{D(1.0, 1.0)}, \textbf{E(4.0, 1.0)}, \textbf{F(0.0, 0.0)}, \textbf{G(3.0, 0.0)}, and \textbf{H(5.0, 0.0)}, the outer hull \textbf{Ho} of \textbf{S} can be computed as the set \textbf{Ho=\{F, H, A, F\}}. If we remove \textbf{Ho} from \textbf{S}, we get \textbf{S--Ho = \{B, C, D, E, G\}}. The inner hull \textbf{Hi} of \textbf{S} is computed as the convex hull of \textbf{S--Ho}, namely \textbf{Hi = \{D, G, E, B, D\}}. Now the area inside \textbf{Ho} is \textbf{area(Ho) = 12.5}. The area inside \textbf{Hi} is \textbf{area(Hi) = 6.0}. Thus the area between the outer hull \textbf{Ho} and the inner hull \textbf{Hi} is \textbf{12.5 -- 6.0 = 6.5}. Your problem is, given a set \textbf{S} of \textbf{N} points, to write a program that computes the area between the outer hull \textbf{Ho} of \textbf{S}, and the inner hull \textbf{Hi} of \textbf{S}. \InputFile The input consists of several problem sets. The first line of a problem set will contain the \textbf{problemID} and the value of \textbf{N}. The value of \textbf{N} will not exceed \textbf{1000}. The next \textbf{N} lines of the problem set will contain the value of \textbf{x}- and \textbf{y}-coordinate (separated by a space) of a point, at one point per line. Each coordinate \textbf{x} or \textbf{y} will be a real number not exceeding \textbf{100.0} in absolute value. The lines of the next problem set will immediately follow the previous problem set. A line with \textbf{problemID} of "\textbf{ZZ}" and a value of \textbf{N} of \textbf{0} indicates the end of input. \OutputFile For each problem set, print one line of the form "\textbf{ProblemID id: area}" where \textbf{id} is the \textbf{problemID} given in the input, and \textbf{area} is the area between the outer hull \textbf{Ho} and the inner hull \textbf{Hi} that you computed. Express the area with \textbf{4} decimal places.
Time limit 5 seconds
Memory limit 128 MiB
Input example #1
A1 8
2.0 5.0
2.0 4.0
2.0 2.0
1.0 1.0
4.0 1.0
0.0 0.0
3.0 0.0
5.0 0.0
A2 11
1.0 5.0
5.0 5.0
2.0 4.0
3.0 4.0
2.0 3.0
2.0 2.0
3.0 2.0
1.0 1.0
4.0 1.0
0.0 0.0
4.0 0.0
ZZ 0
Output example #1
ProblemID A1: 6.5000
ProblemID A2: 14.0000
Source ACM ICM Philippines Multi-Provincial Programming Contest 2013