problem
I am not getting any idea about this one. Please help.
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3831 |
3 | Radewoosh | 3646 |
4 | jqdai0815 | 3620 |
4 | Benq | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | gamegame | 3386 |
10 | ksun48 | 3373 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 160 |
5 | -is-this-fft- | 158 |
6 | awoo | 157 |
7 | adamant | 156 |
8 | TheScrasse | 154 |
8 | nor | 154 |
10 | Dominater069 | 153 |
problem
I am not getting any idea about this one. Please help.
Название |
---|
When we enter a barrier, we can move freely inside of this barrier. If we want to go to another barrier from a barrier then we can travel the smallest distance between them, that is max(0, dist(c1, c2) — r1 — r2). We can also consider the start/end as barriers of radius 0. Now do dijkstra in O(N^2) and be happy.
GOOGLE TRANSLATED VERSION OF EDITORIAL (UNDERSTANDABLE):
For simplicity, assume that a barrier of radius 0 is also placed at the starting point $$$(x_s, y_s)$$$ and the end point $$$(x_t ,y_t )$$$.
The start point and end point will be located at the center of each barrier.
When seeking the optimum route from the start point to the end point, Snuke moves only on the line segment connecting the centers of the barriers.
It turns out that you can make the assumption because when moving from one barrier boundary to another.
Is best to move on a line connecting the centers of those barriers, and when moving inside a barrier.
Is not lost even if it goes through the center of the barrier once.
Therefore, consider a graph in which edges are set between all points with the center of each barrier as the vertex, and solve the shortest path problem of this graph.
The cost of the edge connecting the centers of barriers $$$i,j$$$ is $$$w_{ij}$$$.
$$$w_{ij} = \max ( 0,\sqrt{(x i − x j )^2 + (y i − y j )^2} − (r_i + r_j ) ) $$$
It is a shortest path problem with all edge costs nonnegative and can be solved by the Dijkstra method.
The amount of calculation is $$$O(N^2)$$$. However, depending on the implementation, there are cases in which the path that directly moves from the start point to the end point is overlooked. Please be careful.
Once you are inside a circle, you can move to any point inside it with no cost. The cost is just to jump from a circle to another one that doesn’t intersect with it. So the problem now is to compute the minimum distance from a circle to another one (by traveling through other circles). The minimum distance from a circle centered at $$$P_0$$$ with radius $$$r_0$$$ to a circle centered at $$$P_1$$$ with radius $$$r_1$$$ is $$$dist(P_0, P_1) - r_0 - r_1$$$ if the don’t intersect, otherwise the cost is $$$0$$$. So perform dijkstra algorithm and done. Since this graph is dense, it’s better option using $$$O(n^2)$$$ dijkstra.