Free Solo

시간 제한5초메모리 제한2048 MB

요약
네 팔다리 중 최소 세 개를 서로 다른 홀드에 붙인 채 목표 홀드에 닿을 때까지 이동하는 최단 경로의 길이를 구한다.
난이도

어려움10점 중 8점

유형
기하, 그래프, 최단 경로, 시뮬레이션
정답자
아직 제출이 없습니다

문제

Alex is a climber who is planning his next free solo expedition. He wants to do a completely new climb this time, one that nobody else has done before. Before he starts the climb, he wants to get a rough idea of what the shortest path to the top is.

In climbing, Alex uses his hands and feet to hold on to "holds," which are points on the wall he is climbing where he can put either his hands or feet to stabilize himself.

In this simplified simulation of the route, Alex is modelled as a single point, from which 4 limbs of up to length 1 extend out from. Holds on the wall are also single points, and can be used by any of his limbs, but one hold can only be used by one limb at a time. In order to stay safe, Alex must ensure that at least 3 of his limbs are attached to holds at all times during the climb.

Alex starts at coordinate (0,0)(0, 0) on 3 holds located at (−0.2,0)(-0.2, 0), (0,0)(0, 0), and (0.2,0)(0.2, 0) and has a target hold at (T_x,T_y)(T\_x, T\_y) he is trying to reach. Find the length of the shortest path traced out by Alex's location until he is able to put one limb on the target hold. Alex's location is allowed to be anywhere on the wall as long as he stays safe, including locations with negative y-coordinates.

Guarantees:

  • No two holds will be within 10−310^{-3} units of each other.
  • No two holds will be within 10−310^{-3} units of being distance 2 apart from each other.
  • There will not exist a location on the wall where Alex is able to reach more than 6 holds.
  • If Alex's reach increases or decreases by up to 10−610^{-6}, the length of the shortest path will not change by more than 10−510^{-5}.

입력

The first line contains an integer nn (1≤n≤30)(1 \le n \le 30), the number of holds.

The next nn lines contain two floating point numbers, the xx and yy coordinates of each hold (−10≤x≤10,0≤y≤10)(-10 \le x \le 10, 0 \le y \le 10).

Floating point numbers will be expressed to exactly 5 decimal places.

The three starting holds are not included in the input. The target hold is the last hold given.

출력

Output the length of the shortest safe path to the target hold, or −1-1 if no such path exists. Your answer will be accepted if the absolute or relative error is within 10−410^{-4} of the judge's answer.

예제3

  1. 예제 1

    입력
    1
    0.00000 1.50000
    
    예상 출력
    0.5000000000
    
  2. 예제 2

    입력
    1
    0.00000 2.50000
    
    예상 출력
    -1
    
  3. 예제 3

    입력
    4
    0.00000 0.50000
    -0.80000 1.50000
    0.80000 1.50000
    0.70000 2.20000
    
    예상 출력
    1.3647093219