编程介的小学生 2017-10-18 21:05 采纳率: 20.5%
浏览 806
已采纳

Escape of Life and Death

Description

During his ambitious adventure in search of treasure, Yangyang discovered an ancient underground palace. After thoroughly exploring the palace, he found that it was constructed with elaborately decorated chambers connected by fortified corridors. Out of an explorer’s instinct, he sketched a complete map of the palace before entering the largest and most magnificent chamber, which lied in the heart of the palace.

Standing at the center of the chamber, Yangyang looked around and was profoundly amazed by those vivid, huge statues of the gods. He recognized the tallest one, which depicted God Proxima holding his sacred cane. All of a sudden, a voice took Yangyang by surprise, “Leave now, you stupid human!” It was loud but sounded as if it came from the distance. A thought of danger immediately flashed through Yangyang’s mind: his intrusion into the palace had triggered a spell of destruction. Now an earthquake was emerging from right under the chamber and growing more and more violent. He must escape from underground for life as quickly as possible.

Yangyang knew that seismic waves propagated isotropically at a constant speed. If they spread across any chamber, the chamber would collapse, trap anybody inside and become impassable. However, the corridors were adequately solid to stand any impact of earthquake. Driven by his fearless but obstinate character, Yangyang would only allow himself to run from one chamber to another one which was farther away from the epicenter except when he was going to run toward chamber n + 1.

Yangyang had measured the location of each chamber and estimated the time he needed to run through each corridor. How soon could he accomplish the escape of life and death?

Input

The input consists of a single test case. The first line of input contains three integers n, m, v (1 ≤ n ≤ 50,000, 1 ≤ m ≤ 200,000, 1 ≤ v ≤ 1,000). Next come n lines, each containing a pair of integers (xi, yi) (�6�1109 ≤ xi, yi ≤ 109, �6�61 ≤ i ≤ n). The following m lines each contains three integers ai, bi, ti (0 ≤ ai, bi ≤ n + 1, 1 ≤ ti ≤ 1,000, �6�61 ≤ i ≤ m). The last line contains two pairs of integers (x0, y0), (xn+1, yn+1) (�6�1109 ≤ x0, y0, xn+1, yn+1 ≤ 109).

There were n + 2 chambers in total, numbered 0 through n + 1. Chamber 0 was where Yangyang found the statue of God Proxima; chamber n + 1 was located, as the only exception, on the ground and would not trap Yangyang even if it collapsed. Chamber i (1 ≤ i ≤ n) was located at (xi, yi). Corridor i (1 ≤ i ≤ m) connected chambers ai and bi, and Yangyang needed ti units of time to run through it. Seismic waves propagated at constant speed v.

Output

If Yangyang could escape, output the minimum time he needed; otherwise, output “Impossible”.

Sample Input

1 2 1
3 4
0 1 5
1 2 5
0 0 6 8
Sample Output

Impossible

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-11-02 14:13
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码