#P7000. [NEERC2013] Easy Geometry

[NEERC2013] Easy Geometry

题目描述

Eva studies geometry. The current topic is about convex polygons, but Eva prefers rectangles. Eva's workbook contains drawings of several convex polygons and she is curious what is the area of the maximum rectangle that fits inside each of them.

Help Eva! Given the convex polygon, find the rectangle of the maximum possible area that fits inside this polygon. Sides of the rectangle must be parallel to the coordinate axes.

输入格式

The first line contains a single integer nn -- the number of sides of the polygon (3n100000)(3 \le n \le 100 000) . The following nn lines contain Cartesian coordinates of the polygon's vertices -- two integers xix_{i} and yi(109xi,yi109)y_{i} (-10^{9} \le x_{i}, y_{i} \le 10^{9}) per line. Vertices are given in the clockwise order.

The polygon is convex.

输出格式

Output four real numbers xmin,ymin,xmaxx_{mi_n}, y_{mi_n}, x_{max} and ymaxy_{max} -- the coordinates of two rectangle's corners (xmin<xmax,ymin<ymax).(x_{mi_n} < x_{max}, y_{mi_n} < y_{max}). The rectangle must fit into the polygon and have the maximum possible area.

The absolute precision of the coordinates should be at least 105.10-^{5}.

The absolute or relative precision of the rectangle area should be at least 105.10^{-5}. That is, if AA' ; is the actual maximum possible area, the following must hold: min(AA,AA/A))105.mi_n(|A-A'|,|A−A'|/A') ) \le 10^{-5}.

题目大意

一句话题意:

给你一个凸 nn 边形,并按顺时针给出每一个顶点的坐标,求出在这个凸 nn 边形之内的面积最大的一个边平行坐标轴的矩形的四个顶点。

输入格式:

第一行是一个正整数 nn ,且 3n1000003\le n \le 100000

接下来 nn 行,每行两个整数 xxyy ,代表一个顶点的 xx 坐标和 yy 坐标。 109x,y109-10^9 \le x,y \le 10^9

输出格式:

输出四个整数 xmin,ymin,xmax,ymaxx_{min},y_{min},x_{max},y_{max} ,代表你给出的这个面积最大的矩形。其中 xminxmaxx_{min} \le x_{max} yminymaxy_{min} \le y_{max}

精度要求:如果 AA 是你算出的值, AA' 是真实的最大面积,那么你需要保证 min(AA,AA/A)105min( |A-A'|,|A-A'|/A') \le10^{-5}

4
5 1
2 4
3 7
7 3

3.5 2.5 5.5 4.5

5
1 1
1 4
4 7
7 4
7 1

1 1 7 4

提示

Time limit: 1 s, Memory limit: 128 MB.