CF1044C.Optimal Polygon Perimeter

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given nn points on the plane. The polygon formed from all the nn points is strictly convex, that is, the polygon is convex, and there are no three collinear points (i.e. lying in the same straight line). The points are numbered from 11 to nn , in clockwise order.

We define the distance between two points p1=(x1,y1)p_1 = (x_1, y_1) and p2=(x2,y2)p_2 = (x_2, y_2) as their Manhattan distance: $$$$d(p_1, p_2) = |x_1 - x_2| + |y_1 - y_2|. $$

Furthermore, we define the perimeter of a polygon, as the sum of Manhattan distances between all adjacent pairs of points on it; if the points on the polygon are ordered as p_1,p_2,ldots,p_kp\_1, p\_2, \\ldots, p\_k (kgeq3)(k \\geq 3) , then the perimeter of the polygon is d(p_1,p_2)+d(p_2,p_3)+ldots+d(p_k,p_1)d(p\_1, p\_2) + d(p\_2, p\_3) + \\ldots + d(p\_k, p\_1) .

For some parameter kk , let's consider all the polygons that can be formed from the given set of points, having any kk vertices, such that the polygon is not self-intersecting. For each such polygon, let's consider its perimeter. Over all such perimeters, we define f(k)f(k) to be the maximal perimeter.

Please note, when checking whether a polygon is self-intersecting, that the edges of a polygon are still drawn as straight lines. For instance, in the following pictures:

In the middle polygon, the order of points ( p_1,p_3,p_2,p_4p\_1, p\_3, p\_2, p\_4 ) is not valid, since it is a self-intersecting polygon. The right polygon (whose edges resemble the Manhattan distance) has the same order and is not self-intersecting, but we consider edges as straight lines. The correct way to draw this polygon is ( p_1,p_2,p_3,p_4p\_1, p\_2, p\_3, p\_4 ), which is the left polygon.

Your task is to compute f(3),f(4),ldots,f(n)f(3), f(4), \\ldots, f(n) . In other words, find the maximum possible perimeter for each possible number of points (i.e. 33 to nn$$).

输入格式

The first line contains a single integer nn ( 3n31053 \leq n \leq 3\cdot 10^5 ) — the number of points.

Each of the next nn lines contains two integers xix_i and yiy_i ( 108xi,yi108-10^8 \leq x_i, y_i \leq 10^8 ) — the coordinates of point pip_i .

The set of points is guaranteed to be convex, all points are distinct, the points are ordered in clockwise order, and there will be no three collinear points.

输出格式

For each ii ( 3in3\leq i\leq n ), output f(i)f(i) .

输入输出样例

  • 输入#1

    4
    2 4
    4 3
    3 0
    1 3
    

    输出#1

    12 14 
  • 输入#2

    3
    0 0
    0 2
    2 0
    

    输出#2

    8 

说明/提示

In the first example, for f(3)f(3) , we consider four possible polygons:

  • ( p1,p2,p3p_1, p_2, p_3 ), with perimeter 1212 .
  • ( p1,p2,p4p_1, p_2, p_4 ), with perimeter 88 .
  • ( p1,p3,p4p_1, p_3, p_4 ), with perimeter 1212 .
  • ( p2,p3,p4p_2, p_3, p_4 ), with perimeter 1212 .

For f(4)f(4) , there is only one option, taking all the given points. Its perimeter 1414 .

In the second example, there is only one possible polygon. Its perimeter is 88 .

首页