| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 6 초 | 1024 MB | 6 | 3 | 1 | 25.000% |
Dice Poker is a version of Poker that is played using Dice. Two or more people can play this game. The detailed rules of the 2 player version of the game are mentioned in the section: Rules of the Game.
Two players A and B are playing the game of Dice Poker. Being experts in this game, both always play optimally. A always plays to maximize his chance of winning, and B tries to minimize the chance of A winning (draw is fine for B). In the first round, Player A rolls the Dice, followed by player B. You as an onlooker, look closely at the rolls and wonder what will A and B do next, and what is the probability of A winning. Haven't played this game much before, you decide to write a program to predict with what probability will A win this Game after the 2nd (final) round.
Rules of the Game:
In the first round, two players start of by rolling 5 dice each, one after the other. For this problem we shall assume that all Dice are 6 sided and fair containing digits 1 to 6. Then a round of betting happens, which is irrelevant to this problem statement. In the second round the first player picks between 0 to 5 of his currently rolled dice and rolls them again. All the 5 dice are then merged (merge here simply means that all the 5 dice are taken together to form a set, including the ones rolled in the first round and are not re-rolled in the second) to form the final roll (or hand). Then the second player looks at the final hand of the first player and then similarly re-rolls between 0 to 5 dice to get her final hand. The hands are then compared and one with the higher weight wins.
In the real game, in case of a tie both the players share the pot, but since this problem specifically asks for the probability of A winning, we shall assume that a tie is considered as A not winning (hence B wins).
To determine which of the hands has higher weight, following arrangements are considered and are in descending order of weight. The first arrangement beats the second and so on.
Arrangements:
The highest weight arrangement that suits the hand is considered. For example a 5 of a kind is also a 4 of a kind, but the player would naturally call it 5 of a kind. Also in a particular arrangement, the higher weight arrangement is the one with the highest value of the most significant part of the arrangement. If a the tie still remains then it is broken by the next significant part and so on. For Example, In 4 of a kind the most significant part are the 4 dice with the same number. So the arrangement 4, 4, 4, 4, 1 is better than 3, 3, 3, 3, 6. In 3 of a kind the 3 with the same number is the most significant part. However in a 2 pair, there are 2 equally significant parts and the one with the highest number will be considered first for breaking the tie. In the 'Rest' arrangement, first compare the highest numbers of the 2 hands, then the 2nd highest and so on.
First line contains T (T ≤ 10) the number of test cases to follow For each case, the first line contains 5 space separated numbers, the arrangement of the dice after the first round for player A. The second line contains 5 space separated numbers, the arrangement of the dice after the first round for player B. Each of the numbers will be between 1 and 6 inclusive.
Per test case output a single number in a line, giving the probability of A winning. You will need to round it off to 6 decimal places. (0.0000005 -> 0.000001 and 0.0000004 -> 0.000000). Always output exactly 6 decimal places.
5 6 6 6 6 6 1 2 3 4 5 1 2 3 4 5 2 3 4 5 6 1 2 3 1 1 1 2 3 4 5 1 3 1 2 2 2 2 3 4 6 1 1 1 1 1 5 4 5 5 5
0.999871 0.056503 0.430834 0.477623 0.833333
A already has the best possible set (all 6's) so he won't roll again. B has no chance of winning. However she can probably force a draw by throwing all 6's. So the only option for her is to re-roll all the 5 dice. The numbers of possible outcomes are 6*6*6*6*6 out of which only 1 will force a draw. So the answer is 1 - (1/6^5).