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:
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.
Migrated from old NTUJ.
ICPC 2008, Amritapuri
No. | Testdata Range | Score |
---|