A single elimination tournament begins with teams numbered 1 through N, where N is a power of 2.
In the first round, teams 1 and 2 compete against each other, teams 3 and 4 compete against each
other, and so on up to teams N-1 and N.
The N/2 losing teams are eliminated, and the N/2 winning teams advance to the second round.
In the second round, the winner of teams 1 and 2 compete against the winner of teams 3 and 4.
The winner of teams 5 and 6 compete against the winner of teams 7 and 8.
The winner of teams N-3 and N-2 compete against the winner of teams N-1 and N.
The tournament continues in this fashion, with half the remaining teams eliminated in each round, until there is only one team left. This team is the winner of the tournament. Obviously, the numeration of the teams is very important for determining the winner. You want your favorite team to win the tournament, so you want to find the order which gives your team the best chances to become the winner.
You will be given a String[] chances that contains exactly N elements, each containing exactly N space-separated probabilities.
The j-th number in the i-th element of chances represents the probability (in percents) that team i will win a game against team j.
The 1-based index of your favorite team in chances is team.
You are to order the teams in such a way that your team will have the highest probability to win the tourney and return this probability as a double.
See examples for further clarification.
|