#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 ). Now assume that in each , theoretically unit of can only produce unit of . However, actual experiments show that perfectly complete chemical conversion does not exist. Let the conversion rate be (i.e., unit of actually produces units of , where ).
In the juruo HansBug’s knowledge base there are such conversions. In this problem, HansBug needs to produce compound starting from unit of compound . 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: , 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 ().
Lines to each contain two integers and one real number: , indicating that the -th reaction converts unit of compound into units of compound .
Output Format
Output one line containing a real number: the final yield along the optimal route (rounded to 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 and Sample , the two synthesis routes are , , , with yields , , , respectively.
In Sample , there are two feasible routes, and . Their final yields are and , respectively, so the second route is better, with a yield of .
In Sample , can only produce , and cannot produce any other compound, so synthesis is impossible, and the juruo HansBug has to output orz.
Constraints

Translated by ChatGPT 5
京公网安备 11011102002149号