#P2531. [SHOI2001] 三国围棋对抗赛

[SHOI2001] 三国围棋对抗赛

Description

The rules are as follows: first, a draw determines the team that has a bye in round 11. Then the No. 11 players of the two non-bye teams play; the loser is eliminated. Thereafter, in each round, the previous winner plays against the smallest-index remaining player from the team that had the bye in the previous round. This continues until only one country still has players remaining; that country wins.

Note: When only two teams still have players not eliminated, ignore byes. In each round, the two smallest-index players from those two teams play, and the loser is eliminated.

Input Format

The first line contains a number nn (5n15)(5 \le n \le 15), the number of candidates for Team China.

Then follow nn lines, each containing 1010 numbers.

In line i+1i+1 (1in)(1 \le i \le n), the 1010 numbers are the win probabilities of Chinese candidate ii against Korea No. 151 \sim 5 and Japan No. 151 \sim 5, respectively; each probability is kk (0k1)(0 \le k \le 1).

Next are 55 lines, each containing 55 numbers.

In line n+i+1n+i+1 (1i5)(1 \le i \le 5), the jj-th number is the win probability that Korea player ii defeats Japan player jj.

Output Format

Output a single line: the maximum winning probability for Team China, to 66 decimal places.

5
0.902 0.540 0.862 0.283 0.498 0.597 0.900 0.076 0.750 0.539 
0.342 0.574 0.743 0.442 0.579 0.502 0.755 0.649 0.835 0.278 
0.105 0.704 0.274 0.733 0.725 0.861 0.007 0.314 0.099 0.542 
0.785 0.754 0.541 0.331 0.430 0.426 0.928 0.385 0.314 0.892 
0.349 0.354 0.408 0.353 0.333 0.180 0.715 0.013 0.563 0.386 
0.131 0.564 0.265 0.700 0.033 
0.293 0.688 0.140 0.130 0.550 
0.346 0.915 0.385 0.536 0.946 
0.739 0.051 0.682 0.166 0.436 
0.122 0.065 0.724 0.934 0.736

0.529237

Hint

Translated by ChatGPT 5