#P4190. [CTSC2010] 三国围棋擂台赛
[CTSC2010] 三国围棋擂台赛
Description
The annual “Nongshim Cup” three-nation Go relay tournament is the highest-level Go competition in the world and the most exciting contest among China, Japan, and Korea. This problem is based on the rules of that event.
The three-nation Go relay tournament is a match among national teams of three countries. The rules are briefly as follows:
-
Let the three countries be , , and . Each country has players (in the real event above, ), named , , and .
-
Every game has a winner and a loser. The loser of a game is eliminated.
-
The first player to appear for each team is fixed to be that team’s -th player, i.e., , , and .
-
One team is drawn uniformly at random. That team has a bye in round 1, and the -th players of the other two teams play the first game.
-
The winner of the first game (the “winner” here always means the player who wins that game) plays the -th player of the team that had the bye in the second game. For example, if defeats in the first game, then the second game is vs. .
-
From the third game onward, the team that did not participate in the previous game selects one not-yet-eliminated player to play against the previous game’s winner.
-
This process continues until all players of some team have been eliminated.
-
When only two teams remain, after each game, the losing side chooses one not-yet-eliminated player to play the next game against the winner.
-
When all players of either of the two remaining teams are eliminated, the match ends, and the remaining team wins the Nongshim Cup.
A new edition of the tournament is about to begin. As the leader of Team , you have computed the win probabilities among all players — that is, for any two players and from different teams, we know that the probability that defeats is (), and the probability that defeats is .
Since your country is overwhelmingly strong, assume the other two teams will both target you. Every decision by Teams and — i.e., the order in which they send players — aims to minimize the probability that Team wins the title, while Team ’s decisions aim to maximize that probability. Your task is to compute, under this highly unfavorable scenario and assuming all three sides play optimally, the expected probability that Team wins the championship.
About the expectation: suppose the current game is between players and , and defeats with probability . Then Team ’s winning expectation at this moment is , where is the expectation that Team wins the title after defeats , and is the expectation after defeats . and are computed recursively using the same formula.
Team ’s decisions will maximize this expectation, while Teams and will minimize it. If all players of Teams and are eliminated, the expectation is ; if all players of Team are eliminated, the expectation is .
For example, when each team has players, the head-to-head win probabilities are given by the following three matrices. In each matrix, every value is the row player’s probability of defeating the column player, and the column player’s probability of defeating the row player is .

The third players of the three teams are of equal strength. After the first two games, the probability that the current winner comes from any of the three teams is the same. Suppose the winner of the second game is , and in the third game it is Team ’s turn to send a player. Team can choose between and .
If we send , although the third game is guaranteed to defeat (win probability ), Team will send in the fourth game, against whom surely loses (win probability ). In the fifth game, Team will send , and in the sixth game only can be sent. Since , who surely defeats , has not yet appeared, will be eliminated sooner or later, and Team ’s winning probability is .
If we send , although the win probability against in this game is only , the probability of winning the championship is . Therefore, in the third game we should send .
Considering the six possible pairs of players in the third game, the final expected championship probability is:
$$\dfrac{(6.25\%+3.125\%+18.75\%+25\%+60.9375\%+50\%)}{6} = 27.34375\%.$$Input Format
The input file is go.in.
The first line contains an integer , the number of players on each team.
Lines to each contain real numbers, forming an matrix that gives Team ’s win probabilities against Team . In particular, on line , the -th number is the probability that player defeats player .
Line is a blank line.
Lines to each contain real numbers, forming an matrix that gives Team ’s win probabilities against Team . In particular, on line , the -th number is the probability that player defeats player .
Line is a blank line.
Lines to each contain real numbers, forming an matrix that gives Team ’s win probabilities against Team . In particular, on line , the -th number is the probability that player defeats player .
Output Format
The output file go.out contains a single real number with decimal places, the probability that Team wins the championship.
3
1.0 0.0 0.5
0.5 1.0 1.0
0.5 0.5 0.5
0.5 0.5 1.0
0.5 0.0 0.5
0.5 0.5 0.5
0.5 0.0 1.0
0.5 0.5 0.5
0.5 0.5 0.5
0.273438
Hint
- For of the testdata, .
- For of the testdata, .
- For of the testdata, .
- For of the testdata, in each of the three win-probability matrices, every matrix has constant entries (all elements in a given matrix are the same), but different matrices may have different values.
Translated by ChatGPT 5
京公网安备 11011102002149号