시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
4 초 | 1024 MB | 48 | 14 | 12 | 28.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:
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)$.
번호 | 배점 | 제한 |
---|---|---|
1 | 11 | $X≤2000$ $Y≤2000$ |
2 | 7 | $X≤400$ $N≤50000$ $M≤400$ |
3 | 10 | $X≤400$ $N≤50000$ $M≤50000$ |
4 | 23 | $M=0$ |
5 | 25 | $c_1 = c_2 = ...= c_{Y-1}$ |
6 | 24 | This subtask has no additional constraints. |
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
12 15 11 6 5 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
3 9 18 22 24 30 26 22 16 8
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
11 18 27 34 33 30 27 23 22 16