3509. Bearly Made It

单测试点时限: 4.0 秒

内存限制: 512 MB

Barney the polar has wandered off on an adventure. Lost in thought, he suddenly realizes he has strayed too far from his mother and is stuck on an ice shelf. He can still see her in the distance, but the only way back is by crossing a group of other ice shelves, all of which are perfectly circular. He is very scared, and can not swim. Barney’s mother, getting a little tired of her son’s shenanigans, decides to wait and let him figure this out for himself. Can you help Barney get home? He is in a hurry.

输入

The first line of input contains four integers, , where is Barney’s location and is the location where Barney’s mom is waiting.

The next line contains a single integer , the number of ice shelves.

After this lines follow. Each line holds three integers: and , the coordinates of the center of the shelf and its radius. A shelf consists of all points at distance or less to .

Both bears are on a shelf at the start of Barney’s journey home. Shelves can both touch and overlap.

输出

The minimal distance Barney has to travel to be reunited with his mother. The result should have a relative error of at most .

If there is no way for Barney to make it home, output impossible. (Do not worry about Barney’s well-being in this scenario. His mother will swim out to save him.)

样例

Input
0 0 6 0
2
1 1 2
5 1 2
Output
6.32455532034
Input
0 0 7 0
2
1 1 2
6 1 2
Output
impossible
Input
0 0 1 3
3
0 -1 2
4 -1 3
2 3 2
Output
4.269334912857045697

1 人解决,6 已尝试。

1 份提交通过,共有 18 份提交。

9.9 EMB 奖励。

创建: 9 月,1 周前.

修改: 9 月,1 周前.

最后提交: 8 月,2 周前.

来源: BAPC 17

标签