#P3787. 冰精冻西瓜
冰精冻西瓜
Description
Cirno is a fairy who can control how cold the air is. One day she found a watermelon field. There are watermelons, connected by vines, forming a rooted tree. Cirno wants to freeze them and eat them slowly.
These watermelon vines have a magical property: they can amplify or attenuate the coldness of the passing cold air. Each vine has a multiplier , meaning that after the cold air passes through it, a coldness value becomes . Each watermelon also has a coldness value, and on a hot summer day all watermelons start with coldness .
Cirno performs two types of actions:
①. Release cold air of coldness at watermelon . This cold air spreads along the vines toward the leaves of the "watermelon tree", and its coldness changes according to the above rule. When a watermelon has multiple outgoing vines toward leaf nodes, each vine gets cold air with the same coldness as before the split. Every watermelon along the path adds the current coldness of the air to its own coldness.
The cold air only spreads within the subtree of the release point and never toward the root.
⑨. Ask for the coldness value of watermelon .
Wait, why is there a ⑨? Because silly Cirno herself sometimes forgets how much ice she has released.
So please help her compute it.
Input Format
The first line contains an integer , the number of watermelons.
The watermelons are numbered to , and is the root of this "watermelon tree".
The next lines each contain two integers , and a real number , indicating that there is a vine between watermelons and , and its amplification/attenuation multiplier is .
The next line contains an integer , the number of operations.
Each of the next lines contains either two integers, or two integers and a real number.
The first number can only be or .
If it is , then an integer and a real number follow, meaning to release cold air of coldness at watermelon .
If it is , then an integer follows, meaning to query the coldness value of watermelon .
Output Format
For each operation ⑨, output one line with a real number, the coldness value of the corresponding watermelon.
4
1 2 1.00000000
2 3 0.00000000
3 4 1.00000101
9
1 1 3.00000000
9 2
9 3
1 2 1.42856031
9 4
9 2
1 3 4.23333333
9 2
9 4
3.00000000
0.00000000
0.00000000
4.42856031
4.42856031
4.23333761
Hint
A subtask may have the following special property:
The "watermelon tree" degenerates into a chain.
All real numbers in the input keep 8 decimal places. A solution is accepted if and only if the absolute error from the standard answer is at most . Please pay special attention to floating-point precision.

In the actual testdata, the range of the coldness of the cold air is .
(In the samples, the range of the coldness is .)
Problem setter: orangebird, thanks to oscar.
Translated by ChatGPT 5
京公网安备 11011102002149号