Editorial for COCI '12 Contest 5 #6 Mnogomet
Submitting an official solution before solving the problem yourself is a bannable offence.
Before understanding the solution of the problem itself, some basic probability theory is required.
Independent events. If two events are independent, the probability of both events being realized is equal to the product of their individual probabilities.
Total probability. A complete set of alternatives is a set of disjoint events which together cover the entire sample space. If the only methods available to commute to school are by tram or on foot, then those two events form a complete set of alternatives for commuting to school. Now, the probability of an event in the same space can be expressed as follows:
For the commuting to school example, it can be applied as: the probability of arriving to school today (
Input. From the input data it is possible, in a straightforward way, to find the probability of a player
Computation. We will solve the problem in two steps. In the first step, we find the probabilities of events of the following types:
where
In the second step, we can ignore the individual players and their probabilities; the state is modelled by {current result, team, number of seconds}, with the value being the probability that after the number of seconds since game start, the team has just scored a goal, leading to the current result. For each state, the previous result is uniquely determined. The required probability can be decomposed to a complete set of alternatives which describe the second and the team that scored a goal in that second leading to that previous result. The solution for the current state is obtained as the sum, over all the alternatives, of the products of the probability of the alternative and the probability of a goal just being scored to obtain the current result, which can be read from the array
Output. The probability of an outcome can also be decomposed to a complete set of alternatives, describing the second when the last goal was scored. There must have been no scored goals from that moment to the end of the game, which is included by multiplying the probability from the second step with the
However, if we are processing a winning result (with
Comments