| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 6 초 | 1024 MB | 40 | 9 | 7 | 23.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 | 11 | $N\le100$ |
| 2 | 12 | $N\le1000$ |
| 3 | 25 | All $A_i$ are distinct. |
| 4 | 52 | No additional constraints. |
4 10 5 0 4 3 2 0 3 1 7 2 6 9 3 7 8 4
13 21 9 24
4 10 3 4 5 5 7 0 4 6 5 0 6 5 8 0 7 7
25 16 25 7
2 7 2 0 5 3 3 0 2 4
-1 -1
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
1017 1009 1014 1007 9 1005 9 13