#P2784. 化学1(chem1)- 化学合成

化学1(chem1)- 化学合成

Description

In front of the juruo HansBug is a chemical synthesis problem. As far as he knows, answers are usually written in the following format:

(continued on the next line)

A brief explanation: each compound can produce another compound through a one-step reaction (call this a one-step reaction, denoted as ABA \rightarrow B). Now assume that in each ABA \rightarrow B, theoretically 11 unit of AA can only produce 11 unit of BB. However, actual experiments show that perfectly complete chemical conversion does not exist. Let the conversion rate be CC (i.e., 11 unit of AA actually produces CC units of BB, where 0<C<10 < C < 1).

In the juruo HansBug’s knowledge base there are NN such ABA \rightarrow B conversions. In this problem, HansBug needs to produce compound TT starting from 11 unit of compound SS. But his brain cells and RP are exhausted, so the arduous task of finding the synthesis route with the highest final yield is handed over to you!

Input Format

The first line contains four integers: N,M,S,TN, M, S, T, representing the total number of distinct compounds, the number of reactions known to HansBug, the index of the starting compound, and the index of the target compound, respectively (1S,TN1 \le S, T \le N).

Lines 22 to M+1M+1 each contain two integers and one real number: Ai,Bi,CiA_i, B_i, C_i, indicating that the ii-th reaction converts 11 unit of compound AiA_i into CiC_i units of compound BiB_i.

Output Format

Output one line containing a real number: the final yield along the optimal route (rounded to 44 decimal places). If there is no feasible route, output orz.

3 3 1 3
1 3 0.8
1 2 0.9
2 3 0.9

0.8100
3 3 2 1
1 3 0.8
1 2 0.9
2 3 0.9

orz

Hint

In Sample 11 and Sample 22, the two synthesis routes are 131 \rightarrow 3, 121 \rightarrow 2, 232 \rightarrow 3, with yields 0.80.8, 0.90.9, 0.90.9, respectively.

In Sample 11, there are two feasible routes, 131 \rightarrow 3 and 1231 \rightarrow 2 \rightarrow 3. Their final yields are 0.80.8 and 0.9×0.9=0.810.9 \times 0.9 = 0.81, respectively, so the second route is better, with a yield of 0.81000.8100.

In Sample 22, 22 can only produce 33, and 33 cannot produce any other compound, so synthesis is impossible, and the juruo HansBug has to output orz.

Constraints

Translated by ChatGPT 5