#P13706. [NWERC 2023] Galaxy Quest

    ID: 15515 远端评测题 5000ms 1024MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>数学2023Special Judge最短路ICPC拉格朗日乘数法

[NWERC 2023] Galaxy Quest

题目描述

You are travelling through the galaxy in your spaceship. There are nn planets in the galaxy, numbered from 11 to nn and modelled as points in 33-dimensional space.

You can travel between these planets along mm space highways, where each highway connects two planets along the straight line between them. Your engine can accelerate (or decelerate) at 1m/s2{1}\,\text{m}/\text{s}^2, while using fuel at a rate of 11 litre per second. There is no limit to how fast you can go, but you must always come to a complete standstill whenever you arrive at the planet at the end of a highway.

It is possible for a highway to pass through planets other than the ones it connects. However, as your spaceship is equipped with special hyperspace technology, it simply phases through these obstacles without any need of stopping. Another consequence of using this technology is that it is impossible to jump from one highway to another midway through: highways must always be travelled in full.

:::align{center} Figure G.1: Illustration of Sample Input 1, showing highways in blue, and a route from planet 11 to planet 33. The green start of a highway indicates acceleration, and the red end indicates deceleration. :::

You need to fly several missions, in which you start at your home planet (with number 11) and need to reach a given target planet within a given time limit. For each mission, determine whether it can be completed, and if so, find the least amount of fuel required to do so. As an example, Figure G.1 shows the optimal route for the second mission of the first sample.

输入格式

The input consists of:

  • One line with three integers nn, mm, and qq (1n,m,q1051 \le n,m,q \le 10^5, n2n \ge 2), where nn is the number of planets, mm is the number of space highways, and qq is the number of missions.
  • nn lines, each with three integers xix_i, yiy_i, and ziz_i ($\left|x_i\right|,\left|y_i\right|,\left|z_i\right| \le 10^3$, 1in1 \le i \le n), the coordinates of planet ii.
  • mm lines, each with two integers aa and bb (1a,bn1 \le a,b \le n, aba \neq b), describing a space highway that connects planets aa and bb. It can be traversed in either direction.
  • qq lines, each with two integers cc and tt (2cn2 \le c \le n, 1t1031 \le t \le 10^3), the target planet and time limit for each mission.

The nn planets are in distinct locations. Their coordinates are given in metres, and the time limits of the missions are given in seconds. No two highways connect the same pair of planets. For each mission, both the absolute and relative differences between the given time limit and the shortest possible completion time are at least 10610^{-6}.

输出格式

For each mission, output the least amount of fuel in litres required to reach the target location within the time limit. If the target location cannot be reached within the time limit, output "impossible\texttt{impossible}".

Your answers should have an absolute or relative error of at most 10610^{-6}.

4 4 3
-30 0 0
0 0 0
50 0 0
-30 10 0
1 2
2 3
3 4
4 1
2 10
3 25
4 7
impossible
19.0538441903
4.0000000000
4 2 5
-3 0 2
7 -9 -3
4 4 -6
8 -1 8
1 2
2 3
2 1000
2 100
3 1000
3 100
4 1000
0.0287058122
0.2874671888
0.1120998619
1.1272896971
impossible