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

28060번 - Good Night 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
6 초 1024 MB409723.333%

문제

There are $N$ streetlights on a straight road. The road can be represented as a number line. $i$-th streetlight is located at $X_{i}$ and illuminates $[L_{i}, R_{i}]$ ($X_{i} > 0$). Initially, at the time 0ドル,ドル every streetlights are on. At time $A_i,ドル $i$-th streetlight goes out. After every time $T,ドル if $i$th streetlight is on, it goes out. Precisely, $i$-th streetlight is turned off if it is on at time $A_{i} + kT$ for all non-negative integer $k$. (0ドル < A_i \leq T$)

Azber lives at the origin of the road, i.e. at coordinate 0ドル$. Azber is too scared to pass the point which is not illuminated by any streetlight. (Except for origin he lives) If Azber notices a turned-off streetlight that he can reach from the origin, he runs very fast and turns the streetlight back on. After he turns on a light, he directly comes back to the origin. The speed that Azber moves and lights up streetlights is so fast that the time Azber spent by movement can be ignored.

Over time, some streetlights goes out and is never turned on again. Our challenge is to figure out if each streetlight is permanently turned off. And for the lights which are turned off permanently, calculate the last time the light was on. Let's help timid Azber!

입력

Read the following data from the standard input. All the values in the input are integers.

$N$ $T$

$X_1$ $L_1$ $R_1$ $A_1$

...

$X_N$ $L_N$ $R_N$ $A_N$

출력

Print $N$ lines. For the $i$-th line, if $i$-th streetlight is not turned off permanently, i.e. for any $t>0$ there exists $t' > t$ such that the light is on at $t',ドル print $-1$. Otherwise, print the last time the light was turned on as an integer.

제한

  • 1ドル \leq N \leq 300000$
  • 1ドル \leq T \leq 10^9$
  • 0ドル \leq L_i < R_i \leq 10^9$
  • 0ドル < X_i \leq 10^9$
  • 0ドル < A_i \leq T$

서브태스크

번호배점제한
111

$N\le100$

212

$N\le1000$

325

All $A_i$ are distinct.

452

No additional constraints.

예제 입력 1

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

예제 출력 1

13
21
9
24

예제 입력 2

4 10
3 4 5 5
7 0 4 6
5 0 6 5
8 0 7 7

예제 출력 2

25
16
25
7

예제 입력 3

2 7
2 0 5 3
3 0 2 4

예제 출력 3

-1
-1

예제 입력 4

8 1000
3 0 4 17
6 0 7 9
8 5 9 14
11 1 12 7
15 2 16 9
17 13 18 5
19 10 20 9
21 14 22 13

예제 출력 4

1017
1009
1014
1007
9
1005
9
13

힌트

출처

University > KAIST > KAIST RUN Spring Contest > 2023 KAIST RUN Spring Contest H번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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