#P1769. 淘汰赛制

淘汰赛制

Description

The single-elimination system is a very brutal competition format. There are 2n2^n players numbered 1,2,3,,2n1,2n1, 2, 3, \cdots, 2^n - 1, 2^n, and they will compete for nn rounds. In each round, after sorting all players participating in that round by increasing index, the 11-st plays the 22-nd, the 33-rd plays the 44-th, the 55-th plays the 66-th, and so on. Only the winner of each match advances to the next round (there are no ties). Thus, each round eliminates half of the players. After nn rounds, exactly one player remains, who is the champion.

Now you are given, for every pair of players, the probability that one beats the other. Please predict which player has the highest probability of winning the championship.

Input Format

The first line contains an integer nn (1n101 \le n \le 10), the total number of rounds. Then follow 2n2^n lines, each containing 2n2^n integers; in line ii, the jj-th number is pi,jp_{i,j}. The constraints are 0pi,j1000 \le p_{i,j} \le 100, pi,i=0p_{i,i} = 0, and pi,j+pj,i=100p_{i,j} + p_{j,i} = 100. Here pi,jp_{i,j} denotes the probability (in percent) that player ii defeats player jj.

Output Format

Output a single integer cc, the index of the player whose probability of becoming the champion is the highest (if there are multiple such players, output the smallest index).

2
0 90 50 50
10 0 10 10
50 90 0 50
50 90 50 0

 1

Hint

  • 30%30\% of the testdata satisfies n3n \le 3.
  • 100%100\% of the testdata satisfies n10n \le 10.

Source: NOI Guide 2010 Senior (01).

Translated by ChatGPT 5