CF838E.Convex Countour

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given an strictly convex polygon with n vertices. It is guaranteed that no three points are collinear. You would like to take a maximum non intersecting path on the polygon vertices that visits each point at most once.

More specifically your path can be represented as some sequence of distinct polygon vertices. Your path is the straight line segments between adjacent vertices in order. These segments are not allowed to touch or intersect each other except at the vertices in your sequence.

Given the polygon, print the maximum length non-intersecting path that visits each point at most once.

给你一个严格凸的 nn 个顶点的多边形,保证任意三点不共线。你希望在该多边形的顶点上找出一条最长的、互不相交的路径,其中每个顶点至多被访问一次。

更具体地,你的路径可表示为一个由互异多边形顶点构成的序列。路径由该序列中相邻顶点之间的直线段依次连接而成。这些线段除在序列中的顶点处外,不允许彼此接触或相交。

给定该多边形,请输出满足上述条件的、访问每个顶点至多一次的最长非相交路径的长度。

输入格式

The first line of input will contain a single integer n (2 ≤ n ≤ 2 500), the number of points.

The next n lines will contain two integers x__i, y__i (|x__i|, |y__i| ≤ 109), denoting the coordinates of the i-th vertex.

It is guaranteed that these points are listed in clockwise order.

输入的第一行包含一个整数 nn(2 ≤ n ≤ 2 5002 \leq n \leq 2\,500),表示点的数量。

接下来的 nn 行每行包含两个整数 xi, yix_i,\,y_i(∣xi∣, ∣yi∣ ≤ 109|x_i|,\,|y_i| \leq 10^9),表示第 ii 个顶点的坐标。

保证这些点按顺时针顺序给出。

输出格式

Print a single floating point number, representing the longest non-intersecting path that visits the vertices at most once.

Your answer will be accepted if it has absolute or relative error at most 10 - 9. More specifically, if your answer is a and the jury answer is b, your answer will be accepted if .

输出一个浮点数,表示访问顶点至多一次的最长不相交路径的长度。

若你的答案的绝对误差或相对误差不超过 10−910^{-9},则会被接受。更具体地说,若你的答案为 aa,而标准答案为 bb,则当满足 时,你的答案将被接受。

输入输出样例

  • 输入#1

    4
    0 0
    0 1
    1 1
    1 0

    输出#1

    3.4142135624

说明/提示

One optimal path is to visit points 0,1,3,2 in order.

一条最优路径是按顺序访问点 0、1、3、2。

输入解题思路,AI测评打分。不知道怎么写?

首页