시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 1024 MB48141228.571%

문제

Due to global warming and environmental crisis, we now need to make plans to survive for possible natural disasters. This time, we will make manuals for tsunamis.

The ocean line can be represented as a line parallel to the x-axis, $y=k$. Normally $k$ would be $0$, but when a tsunami occurs it will become a positive real number.

In our city, there will be $N$ evacuation spots represented as points $(p_i, q_i)$. At these spots, we will gather and move simultaneously. Also $r_i$ is given for each spot, which denotes the time (in minutes) for you to go to that particular spot.

There will be obstacles to evacuation. For simplicity, we assume obstacles are straight-lined and parallel to the x-axis.

A total of $M$ obstacles are given as $(s_i, e_i, y_i, t_i)$, which are line segments connecting $(s_i, y_i)$ and $(e_i, y_i)$ that takes $t_i$ minutes to cross. Note that it also takes $t_i$ minutes crossing the obstacle even at the endpoints. No obstacles and evacuation spots coincide.

However obstacles themselves may overlap. In that case, the time crossing the overlapped obstacle is the sum of the overlapping $t_i$s. For example, if there are 2 obstacles $(1, 4, 2, 5)$ and $(3, 5, 2, 7)$, it will take $5$ minutes to cross at $x=1$, $5+7=12$ minutes to cross at $x=3$, $7$ minutes to cross at $x=5$.

We will only move upwards(i.e. +y direction) until we reach $y=Y$, which is the safe zone. While moving upwards, we can move our x-coordinates too. It takes $c_i$ minutes per coordinate to move along the x-axis when our current y-coordinate is between $i$ and $i+1$. For example when $c_3=5$ and we move our x-coordininate from $10$ to $6$ at $y=3.5$, it will take $5\times |10-6|=20$ minutes.

We can only move to integer x-coordinates, and also can safely assume that we don't change x-coordinates at integer y-coordinates. Keep in mind that this is the only constraint. We can move to either $x=-100$ or $x=10^{100}$, if you want.

Also note that $c_1, ..., c_{Y-1}$ is a nondecreasing sequence, since the number of people as $y$ increases will also increase, and therefore it will get harder to move between them.

The evacuation manual is as follows:

  • 1. We move to an appropriate evacuation spot.
  • 2. Starting from the spot, we move to $y=Y$ under the given constraints.

We do not consider time moving simply upwards as it is nearly constant regardless of our starting evacuation spots. We only consider time moving to an evacuation spot, moving horizontally, and crossing obstacles.

Let's calculate the minimum possible time in minutes to evacuate to $(1, Y)$, $(2, Y)$, ..., $(X, Y)$ respectively.

입력

The first line contains two space-separated integers $X$ and $Y$.

The second line contains two space-separated integers $N$ and $M$.

Each of the following $N$ lines contain three space-separated integers $p_i$, $q_i$, $r_i$ which denotes the $i$th evacuation spot.

Each of the following $M$ lines contain four space-separated integers $s_i$, $e_i$, $y_i$, $t_i$ which denotes the $i$th obstacle.

The last line contains $Y-1$ space-sperated integers $c_1$, $c_2$, ..., $c_{Y-1}$. $c_i$ denotes the speed of changing the x-coordinate when your y-coordinate is between $[i, i+1]$.

출력

Print $X$ lines. In the $i$th line, print a single integer denoting the minimum time (in minutes) to reach point $(i, Y)$.

제한

  • $3\leq X, Y\leq 2\times 10^5$
  • $1\leq N\leq 2\times 10^5$
  • $0\leq M\leq 2\times 10^5$
  • $1\leq p_i\leq X$, $1\leq q_i<Y$, $0\leq r_i\leq 10^{15}$
  • $1\leq s_i\leq e_i\leq X$, $2\leq y_i<Y$, $0\leq t_i\leq 10^9$
  • $0\leq c_1\leq c_2\leq ...\leq c_{Y-1}\leq 10^6$

서브태스크

번호배점제한
111

$X≤2000$

$Y≤2000$

27

$X≤400$

$N≤50000$

$M≤400$

310

$X≤400$

$N≤50000$

$M≤50000$

423

$M=0$

525

$c_1 = c_2 = ...= c_{Y-1}$

624

This subtask has no additional constraints.

예제 입력 1

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

예제 출력 1

12
15
11
6
5
2

예제 입력 2

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

예제 출력 2

3
9
18
22
24
30
26
22
16
8

예제 입력 3

10 12
3 7
3 1 8
7 2 4
1 1 7
1 2 6 14
5 10 6 1
1 10 6 5
2 10 9 3
2 7 5 16
8 10 7 10
3 7 9 10
0 1 1 1 3 4 6 8 9 9 9

예제 출력 3

11
18
27
34
33
30
27
23
22
16

출처

University > KAIST > 2023 KAIST RUN Spring Contest F번

채점 및 기타 정보

  • 예제는 채점하지 않는다.