Logo
(追記) (追記ここまで)

34487번 - Walking on Sunshine 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB13121292.308%

문제

I’m walking on sunshine, and it don’t feel good – my eyes hurt!

Baku has plenty of sunshine. If you walk away from the sun, or at least perpendicular to its rays, it does not shine in your eyes. For this problem assume that the sun shines from the south. Walking west or east or in any direction between west and east with a northward component avoids looking into the sun. Your eyes will hurt if you walk in any direction with a southward component.

Baku also has many rectangular areas of shade, and staying in these protects your eyes regardless of which direction you walk in. For example, Figure L.1 shows two shaded areas.

Find the minimum distance you need to walk with the sun shining in your eyes to get from the contest location to the awards ceremony location.

Figure L.1: Sample Input 1 and a path that minimizes the sun shining in your eyes.

입력

The first line of input contains five integers $n,ドル $x_c,ドル $y_c,ドル $x_a,ドル and $y_a,ドル where $n$ (0ドル ≤ n ≤ 10^5$) is the number of shaded areas, $(x_c, y_c)$ is the location of the contest, and $(x_a, y_a)$ is the location of the awards ceremony ($−10^6 ≤ x_c, y_c, x_a, y_a ≤ 10^6$). The sun shines in the direction $(0, 1)$ from south towards north. You look into the sun if you walk in direction $(x, y)$ for any $y < 0$ and any $x$.

The next $n$ lines describe the shaded areas, which are axis-aligned rectangles. Each of these lines contains four integers $x_1,ドル $y_1,ドル $x_2,ドル and $y_2$ ($−10^6 ≤ x_1 < x_2 ≤ 10^6$; $−10^6 ≤ y_1 < y_2 ≤ 10^6$). The southwest corner of the rectangle is $(x_1, y_1)$ and its northeast corner is $(x_2, y_2)$. The rectangles describing the shaded areas do not touch or intersect.

출력

Output the minimum distance you have to walk with the sun shining in your eyes. Your answer must have an absolute or relative error of at most 10ドル^{−7}$.

제한

예제 입력 1

2 1 7 5 1
3 6 5 9
2 3 6 5

예제 출력 1

3.0

예제 입력 2

2 0 10 10 0
2 7 3 8
4 3 8 5

예제 출력 2

7.0

예제 입력 3

2 11 -1 -1 11
2 7 3 8
4 3 8 5

예제 출력 3

0.0

예제 입력 4

3 1 5 9 5
-5 6 2 9
4 7 12 8
1 1 7 3

예제 출력 4

0.0

예제 입력 5

3 1 7 9 3
2 6 3 8
4 4 5 6
6 2 7 4

예제 출력 5

0.0

예제 입력 6

1 0 0 0 0
-5 -5 5 5

예제 출력 6

0.0

노트

출처

ICPC > World Finals > ICPC World Finals 2025 L번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /