아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Glacier Travel

시간 제한2초메모리 제한1024 MB

요약
경로와 호 길이 간격 s가 주어질 때, 같은 속도로 s만큼 떨어져 이동하는 두 사람 사이의 최소 유클리드 거리를 구한다.
난이도

보통10점 중 7점

유형
기하, 투 포인터
정답자
아직 제출이 없습니다

문제

Glaciers are vast rivers of slowly-flowing ice, fraught with crevasses which hide under thin layers of snow and wait for unsuspecting walkers to step into and fall in. To reduce the danger, hikers usually go in teams tied together with a thick rope to reduce the consequences of a fall--if one person falls in, the other person may yet hold them from a safe distance.

Today, you are roped up to cross a glacier with your partner. Your plan is to follow the exact same route, at the same speed, the first starting earlier and the second beginning to trace steps once you are exactly xx metres apart. Were you to follow a completely straight path, you would thus then remain exactly xx metres apart at all time.

Figure G.1: An illustration of the path taken in the 2nd sample case, taken from above. This could also be a particularly festive diagram of someone falling into a crevasse.

However, the twisting nature of the course as you avoid obstacles means that you may not always remain exactly xx metres apart. What is the closest that you shall actually come while both of you are walking on the path?

입력

  • One line containing a real number: the separation distance along the path in metres, ss (1≤s≤10001 \le s \le 1000).
  • One line containing the number of points in the path, nn (2≤n≤1062 \le n \le 10^6).
  • nn further lines, the iith of which contains a pair of integers giving the iith coordinate on the track x_iy_ix\_i y\_i (−106≤x,y≤106-10^6 \le x, y \le 10^6) in metres from the origin.

Every pair of adjacent points on the track are distinct from one another, although the track may cross over or repeat itself. The track is guaranteed to have a length of at least ss.

출력

Output the minimum distance between the two walkers at any point on the route, ignoring any time after the first walker has finished, or before the second walker has started.

The output must be accurate to an absolute or relative error of at most 10−410^{-4}.

예제2

  1. 예제 1

    입력
    5
    4
    20 0
    10 0
    10 10
    0 10
    
    예상 출력
    3.5355339
    
  2. 예제 2

    입력
    3.16227766
    9
    -2 4
    2 4
    3 1
    4 4
    5 1
    6 4
    10 2
    6 1
    7 4
    
    예상 출력
    1