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

31959번 - Shadow Line 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
10 초 (추가 시간 없음) 2048 MB (추가 메모리 없음)109322240.741%

문제

You have a point light source at the origin in the 2D plane. To the right there is an infinitely tall wall. There are some opaque vertical line segments between the light source and the wall. As a result, each line segment casts a shadow onto the wall. All of these shadows overlap to form one or more intervals on the wall.

Now imagine moving the light source along the $x$-axis in the negative direction, effectively pulling the light further away from all the objects in a straight line. As the light source moves, the shadows move as well, potentially changing the number of shaded intervals on the wall. Your job is to compute the sum of the lengths of the intervals along the $x$-axis for which the light source creates a single shaded interval on the wall.

입력

The first line of input contains two integers $n$ (1ドル \leq n \leq 3,000円$) and $w$ (2ドル \leq w \leq 10^6$), where $n$ is the number of opaque vertical segments, and $w$ is the $x$-coordinate of the infinitely tall wall.

Each of the next $n$ lines contains three integers $x$ (0ドル < x < w$), $y_{low}$ and $y_{high}$ ($-10^6 \leq y_{low} < y_{high} \leq 10^6$). Each set of three integers describes a line segment from $(x,y_{low})$ to $(x,y_{high})$. All $y$-coordinates will be unique. No two line segments will intersect or overlap.

출력

Output a single number, which is the sum of the lengths of the intervals along the $x$-axis for which the light source creates a single shaded interval on the wall. If this sum includes an unbounded interval (i.e. there is a single shaded interval when the light source is infinitely far away), print $-1$ instead. Your answer will be accepted if the absolute or relative error is within 10ドル^{-6}$ of the judge's answer.

제한

예제 입력 1

3 20
2 1 3
6 -4 2
12 -10 -5

예제 출력 1

16.0

힌트

출처

ICPC > Regionals > North America > North America Championship > North America Championship 2024 K번

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

출처

대학교 대회

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

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