RGBGame
TCO11 Semifinal 2 · 2011-05-07 · by ivan_metelsky
Problem Statement
The game ends when each of the players has made N-1 moves. At this point, there's just one row and column that have not been crossed out. Consider the color of the cell at this row and column. If it is red, Alice wins, if it is blue, Bob wins, and if it is green, then it's a draw. Both players play optimally, i.e. they aim to win, and if it's impossible, they aim to end the game in a draw.
You are given a
Return a
Notes
- Each element of the return value must have an absolute or relative error of less than 1e-9.
Constraints
- board will contain between 2 and 50 elements, inclusive.
- Each element of board will contain the same number of characters as the number of elements in board.
- Each element of board will contain only the characters 'R', 'G', 'B' and '?'.
Statement by TopCoder, Inc. — view the original on the archive.
{"RG",
"B?"}
Returns: {0.0, 0.0 }
This game always ends in a draw. Alice will cross out row 1 and then Bob will cross out column 0.
{"RR",
"R?"}
Returns: {1.0, 0.0 }
Alice guarantees her win by crossing out row 1.
{"BB",
"B?"}
Returns: {0.0, 1.0 }
Bob can guarantee his win by crossing out column 1.
{"??",
"??"}
Returns: {0.2098765432098766, 0.308641975308642 }
The odds for Bob are almost 1.5 times higher than for Alice. Sounds like not a very fair game.
{"???",
"???",
"???"}
Returns: {0.10704669003708767, 0.34847330183407 }
If I were Alice, I wouldn't like to play this game.
Submissions are judged against all 156 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class RGBGame with a public method vector<double> probabilities(vector<string> board) · 156 test cases · 2 s / 256 MB per case