Submit | All submissions | Best solutions | Back to list |
DICE - Three-sided Dice |
Just like every fall, the organizers of the Southwestern Europe Dice Simulation Contest are busy again this year. In this edition you have to simulate a 3-sided die that outputs each of three possible outcomes (which will be denoted by 1, 2 and 3) with a given probability, using three dice in a given set. The simulation is performed this way: you choose one of the given dice at random, roll it, and report its outcome. You are free to choose the probabilities of rolling each of the given dice, as long as each probability is strictly greater than zero. Before distributing the materials to the contestants, the organizers have to verify that it is actually possible to solve this task.
For example, in the first test case of the sample input you have to simulate a die that yields outcome 1, 2 and 3 with probabilities 3/10, 4/10 and 3/10. We give you three dice, and in this case the i-th of them always yields outcome i, for each i = 1, 2, 3. Then it is possible to simulate the given die in the following fashion: roll the first die with probability 3/10, the second one with probability 4/10 and the last one with probability 3/10.
Input
The input consists of several test cases, separated by single blank lines. Each test case consists of four lines: the first three of them describe the three dice you are given and the last one describes the die you have to simulate. Each of the four lines contains 3 space-separated integers between 0 and 10 000 inclusive. These numbers will add up to 10 000, and represent 10 000 times the probability that rolling the die described in that line yields outcome 1, 2 and 3, respectively.
The test cases will finish with a line containing only the number zero repeated three times (also preceded with a blank line).
Output
For each case, your program should output a line with the word YES if it is feasible to produce the desired die from the given ones, and NO otherwise.
Sample
Input: 0 0 10000 0 10000 0 10000 0 0 3000 4000 3000 0 0 10000 0 10000 0 3000 4000 3000 10000 0 0 0 0 0 Output: YES NO
Problem setter: Abel Molina Prieto
Added by: | David García Soriano |
Date: | 2011-11-24 |
Time limit: | 0.102s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Southwestern Europe Regional, SWERC 2010 |
hide comments
2011-11-25 13:06:35 David García Soriano
Dice is plural, die is singular. So it's correct. |
|
2011-11-25 13:06:35 Problem Solver
"In this edition you have to simulate a 3-sided die" Please correct die to dice :D |