#P8804. Fault Cause Deduction

    ID: 21968 Type: Default 1000ms 256MiB

Fault Cause Deduction

Fault Cause Deduction

In software or system development, various faults may occur. To deduce the cause based on the observed fault phenomena, engineers often use a two-dimensional correlation matrix to represent the relationship between fault causes and fault phenomena. Specifically, each row represents a fault cause and each column represents a fault phenomenon. If a cell has a mark (denoted by an applicable probability value), it means that the corresponding fault cause can produce that fault phenomenon. If there is no mark (represented by a '-' in the input), the fault cause definitely will not produce that phenomenon.

Historically, we have collected the prior probabilities of each fault cause occurring as well as the probabilities that a given fault cause produces each of the fault phenomena. Under the assumption that at any given time there is exactly one fault cause and that the events of producing different phenomena are independent, the probability of a fault cause i producing all the observed phenomena O is:

$$P(i) \times \prod_{j \in O} p_{ij}$$

Then, using Bayes' theorem, the posterior probability for fault cause i given the observed phenomena is:

$$\frac{P(i) \times \prod_{j \in O} p_{ij}}{\sum_{k} \left(P(k) \times \prod_{j \in O} p_{kj}\right)}$$

Given the observed fault phenomena, your task is to compute the posterior probability for each fault cause.

inputFormat

The input begins with three integers n m k where:

  • n is the number of fault causes.
  • m is the total number of fault phenomena.
  • k is the number of observed fault phenomena.

The second line contains k distinct integers (1-indexed) representing the indices of the fault phenomena that have been observed.

Then follow n blocks, each describing a fault cause. For each fault cause:

  • The first line contains a floating-point number representing the prior probability P(i).
  • The second line contains m tokens. Each token is either a floating-point number representing the probability of that fault phenomenon occurring if the fault cause occurs, or a '-' (a single dash) indicating that the fault phenomenon cannot occur for that fault cause.

Note: If a required probability is not provided (i.e. token is '-'), it is considered as 0.

outputFormat

Output n lines. Each line should contain the posterior probability of the corresponding fault cause (in the same order as the input) occurring, rounded to 6 decimal places.

If the total probability for all causes is 0 (i.e. none of the fault causes can produce the observed phenomena), output 0.000000 for each fault cause.

sample

2 4 3
2 3 4
0.3
- 0.333333 0.25 0.5
0.7
0.1 - 0.1 -
1.000000

0.000000

</p>