#P2502. [HAOI2006] 旅行

    ID: 1516 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2006河南并查集各省省选枚举,暴力排序

[HAOI2006] 旅行

Description

Z Town is a picturesque place that attracts tourists from all over. There are nn scenic spots near Z Town (numbered 1,2,3,,n1, 2, 3, \ldots, n), connected by mm roads. All roads are bidirectional, and there may be multiple roads between two spots.

Perhaps to protect local tourism resources, Z Town has a peculiar rule: for a given road rir_i, any vehicle traveling on that road must have speed viv_i.

Frequent speed changes make tourists uncomfortable, so when traveling from one spot to another, everyone wants to choose a route that minimizes the ratio between the maximum and minimum speeds during the trip, i.e., the most comfortable route.

Input Format

The first line contains two positive integers n,mn, m.

Each of the next mm lines contains three positive integers x,y,vx, y, v. This means there is a bidirectional road between spots xx and yy, and vehicles must travel at speed vv on that road.

The last line contains two positive integers s,ts, t, asking for the path from spot ss to spot tt with the smallest ratio of maximum to minimum speeds. ss and tt are not the same.

Output Format

If there is no path from ss to tt, output IMPOSSIBLE. Otherwise, output a number representing the minimal speed ratio. If necessary, output a reduced fraction.

4 2
1 2 1
3 4 2
1 4
IMPOSSIBLE
3 3
1 2 10
1 2 5
2 3 8
1 3
5/4
3 2
1 2 2
2 3 4
1 3
2

Hint

For 100%100\% of the testdata, 1x,yn5001 \le x, y \le n \le 500, 1v<3×1041 \le v < 3 \times 10^4, 1m5×1031 \le m \le 5 \times 10^3, xyx \ne y.

Translated by ChatGPT 5