P2413 yyy loves physics IV
Background
“Tremble, laboratory!”
yyy once again returned to that ravaged laboratory.
Description
This time, the circuit that almost perished heroically in Round 1 has been brought out again. There are $N$ ($1 \le N \le 26$) components.
The physics ace yyy connected them with a bunch of wires—series, parallel, all kinds of combinations...
However, because yyy’s operation was too nonstandard, each component has a risk of being damaged. Using his genius brain, yyy calculated that the probability that component $i$ fails and becomes open is $p_i$ ($0 \le p_i \le 1$). Because the circuit is too complex, yyy asks you to compute the probability that the entire circuit becomes open (disconnected).
Circuit wiring rules:
- A single component is the smallest circuit, with A denoting component 1, B denoting component 2, and so on.
- A series circuit composed of $K$ subcircuits is written as circuit 1, 2, ..., $K$.
- A parallel circuit composed of $K$ subcircuits is written as (circuit 1)(circuit 2)...(circuit $K$).
Input Format
The first line contains an integer $n$, the number of components.
The second line contains a string that describes the circuit.
The next $n$ lines each contain a real number $p_i$, the probability that component $i$ becomes open.
Output Format
Output a real number: the probability that the entire circuit becomes open, accurate to 4 decimal places.
Explanation/Hint
Translated by ChatGPT 5