#C14489. Deterministic Dice Game
Deterministic Dice Game
Deterministic Dice Game
This problem simulates a dice game between two players. Given the names of the two players and a random seed, your task is to simulate rolling two six-sided dice for each player and determine the winner or if the game is tied.
The dice outcomes are determined in a deterministic way based on the seed. For this problem, if the seed is 0, 1, or 2, the dice outcomes are predefined as follows:
- If the seed is 0: the dice rolls are [3, 5, 2, 3] (i.e. Player1 rolls 3 and 5, Player2 rolls 2 and 3), resulting in totals 8 and 5 respectively.
- If the seed is 1: the dice rolls are [1, 3, 6, 4] (i.e. Player1: 1 and 3, Player2: 6 and 4), resulting in totals 4 and 10 respectively.
- If the seed is 2: the dice rolls are [3, 4, 5, 2] (i.e. both players sum to 7).
For any other seed value, you may use any deterministic method for simulating dice rolls, as long as the dice outcomes are computed by generating four integers in the range [1,6].
The result should be printed as a single line. If one player has a higher total than the other, output "X wins with a sum of S1 against S2", where X is the name of the winning player, S1 is the winner's total, and S2 is the other player's total. If both totals are equal, output "It is a tie with both summing to S".
inputFormat
The input is read from stdin and consists of three lines:
- The first line contains the name of the first player (a string).
- The second line contains the name of the second player (a string).
- The third line contains an integer seed to control the dice outcomes.
outputFormat
Output a single line to stdout describing the result. The format should be one of the following:
- If a player wins: "PlayerName wins with a sum of X against Y".
- If there is a tie: "It is a tie with both summing to Z".
Alice
Bob
0
Alice wins with a sum of 8 against 5