An infamous football club (let us call it ) wants to buy yet another competition. There are teams, where for some . As usual, the tournament scheme is a complete binary tree, so will have to win matches to be the champion. The president of knows, for every pair of teams and , the probability that eliminates . So he will bribe the football federation, and arrange the play offs so as to maximize the probability that wins the competition. Can you compute that probability?
Input consists of several cases, each one with
,
followed by
lines with
probabilities each, where the
-th
number of the
-th
line is
.
Assume
,
that
for every
,
and that the diagonal of the matrix has only -1.
is the first team.
For every case, print the probability with four digits after the decimal point. The input cases have no precission issues.
The expected solution is a “reasonable” backtracking. For instance, 2000 tests with should be solved in at most one second.
Input
2 -1 0.6 0.4 -1 4 -1 1 0.5 0 0 -1 0.7 0.8 0.5 0.3 -1 0.1 1 0.2 0.9 -1 8 -1 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.9 -1 0.9 0.8 0.7 0.6 0.5 0.4 0.8 0.1 -1 0.1 0.2 0.3 0.4 0.5 0.7 0.2 0.9 -1 0.5 0.6 0.7 0.8 0.6 0.3 0.8 0.5 -1 0.2 0.4 0.6 0.5 0.4 0.7 0.4 0.8 -1 0.8 0.4 0.4 0.5 0.6 0.3 0.6 0.2 -1 0.3 0.3 0.6 0.5 0.2 0.4 0.6 0.7 -1
Output
0.6000 0.4000 0.1100