10297_DetourBuster

2022-5-16 18:16| 发布者: Hocassian| 查看: 52| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-89504740833399-Problem List-采集的数据-后羿采集器.html

Pro.ID

10297

Title

Detour Buster

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=10297

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    The Green Parcel Services company employs cyclists to deliver parcels across a large metropolitan city, and employees are paid according to the distances they must travel to deliver parcels. Each company bicycle has been equipped with a global positioning system that records its position once every couple of seconds. The sequence of positions for one delivery is called a track and the length of a track, which is the sum of euclidean distances between consecutive pairs of recorded points, is used to calculate the employee's payment.

    A recent audit of the recorded tracks revealed that some tracks self-intersect, which indicates that some employees are making unnecessary detours. Your task is to write a program to process a given track and calculate the length of the shortest possible track from the first to the last point of the original track. The shortest possible track must be part of the original track and may include travelling in the same or opposite direction along the original track.

    输入

    Input starts with an integer, on a line by itself, that represents the number of tracks to be shortened. The description of each track begins with a positive integer N, on a line by itself, representing the number of recorded points that define the track. Each of the following N lines contains two integers, separated by a single space, that define the x- and y-coordinates of a point on the track in metres. The points are listed in order of their appearance on the track.

    Two successive points, which form a segment, will be no more than thirty metres apart and a segment will not intersect more than twenty other segments. All x- and ycoordinates have values between -10,000,000 and 10,000,000, inclusive. N has values between 1 and 100,000, inclusive.

    输出

    Description

    The Green Parcel Services company employs cyclists to deliver parcels across a large metropolitan city, and employees are paid according to the distances they must travel to deliver parcels. Each company bicycle has been equipped with a global positioning system that records its position once every couple of seconds. The sequence of positions for one delivery is called a track and the length of a track, which is the sum of euclidean distances between consecutive pairs of recorded points, is used to calculate the employee's payment.

    A recent audit of the recorded tracks revealed that some tracks self-intersect, which indicates that some employees are making unnecessary detours. Your task is to write a program to process a given track and calculate the length of the shortest possible track from the first to the last point of the original track. The shortest possible track must be part of the original track and may include travelling in the same or opposite direction along the original track.

    Input

    Input starts with an integer, on a line by itself, that represents the number of tracks to be shortened. The description of each track begins with a positive integer N, on a line by itself, representing the number of recorded points that define the track. Each of the following N lines contains two integers, separated by a single space, that define the x- and y-coordinates of a point on the track in metres. The points are listed in order of their appearance on the track.

    Two successive points, which form a segment, will be no more than thirty metres apart and a segment will not intersect more than twenty other segments. All x- and ycoordinates have values between -10,000,000 and 10,000,000, inclusive. N has values between 1 and 100,000, inclusive.

    Output

    For each input track, the output consists of a single integer, on a line by itself, which is the length of the shortest track in metres. The answer must be rounded to the nearest integer value.

    Reminder: Rounding a positive number R.xyz to the nearest integer

    • If the first decimal place (that is x) is less than 5, then the rounded value is R

    • Otherwise, the rounded value is R+1

    Sample Input

    25
    0 0
    12 0
    20 0
    10 10
    10 -10
    6
    0 0
    15 0
    10 -5
    4 1
    10 1
    10 -10

    Sample Output

    20
    17

    Source

    样例输入

    25
    0 0
    12 0
    20 0
    10 10
    10 -10
    6
    0 0
    15 0
    10 -5
    4 1
    10 1
    10 -10

    样例输出

    20
    17

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部