P28296 [洛谷] [HAOI2006] Travel
提高
题目描述

Problem Description

Z Town is a picturesque place that attracts tourists from all over the world. There are a total of $n$ attractions (numbered $1, 2, 3, \ldots, n$) in the vicinity of Z Town, connected by $m$ bidirectional roads. There may be multiple roads between two attractions.

Perhaps to protect the local tourism resources, Z Town has a peculiar rule: for a given road $r_i$, any vehicle traveling on this road must maintain a speed of $v_i$.

Sudden changes in speed make tourists uncomfortable. Therefore, when traveling from one attraction to another, everyone hopes to choose a route where the ratio of the maximum speed to the minimum speed is as small as possible, which is known as the most comfortable route.

Input Format

The first line contains two positive integers $n$ and $m$.

The next $m$ lines each contain three positive integers $x$, $y$, and $v$. This indicates that there is a bidirectional road between attraction $x$ and attraction $y$, and vehicles must travel at speed $v$ on this road.

The last line contains two positive integers $s$ and $t$, indicating that you want to find the path with the smallest ratio of maximum to minimum speed from attraction $s$ to attraction $t$. $s$ and $t$ will never be the same.

Output Format

If there is no path from attraction $s$ to attraction $t$, output IMPOSSIBLE. Otherwise, output a number representing the smallest speed ratio. If necessary, output a reduced fraction.

Sample Input and Output

Sample Input #1

4 2
1 2 1
3 4 2
1 4

Sample Output #1

IMPOSSIBLE

Sample Input #2

3 3
1 2 10
1 2 5
2 3 8
1 3

Sample Output #2

5/4

Sample Input #3

3 2
1 2 2
2 3 4
1 3

Sample Output #3

2

Notes

For $100\%$ of the data, $1 \le x, y \le n \le 500$, $1 \le v < 3 \times 10^4$, $1 \le m \le 5 \times 10^3$, and $x \ne y$.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 2 1 2 1 3 4 2 1 4
样例输出
IMPOSSIBLE