eolymp
bolt
Try our new interface for solving problems
Problems

Probable diagnosis

Probable diagnosis

As a course project Alex designs hospital information system. Now he needs to write a component which puts a tentative diagnosis based on statistical data. The program is loaded with information about N diseases and M possible symptoms. For each disease the chance that the patient appears to have each symptom is known. Similar information is known for healthy people. Alex assumes, that each of the patients has no more than one disease, and if disease has been cured (or doesn’t exist), the various symptoms will occur independently. The program loads information about K patients. For each particular patient it is known that some symptoms occur, and some do not, others have not been tested. We need to determine the possibility of this patient to be sick with every known disease. \textbf{Limit} 1 \textit{≤ N ≤ }200 1 \textit{≤ M ≤ }200 1 \textit{≤ K ≤ }200 \InputFile The first line contains two integers : N and M. The next line contains M numbers --- the probability that healthy person has corresponding symptom. The following N lines contain information about diseases. Each of them contains M + 1 numbers: the probability that a person is sick with this disease (sum of the probabilities of all the diseases is less than 100\%), and the probability of occurrence of each symptom, if a person is sick with the disease. The next line contains a single integer K. The following K lines contain information about patients: each of them contains a string M long, each of the symbols of which is +, if the patient appears to have the corresponding symptom, -, if it doesn’t appear, or ?, if there is no detailed information about it. All probabilities in the input file are specified in percentages, each value is a number from 0 to 100 with exactly two digits after the dot. It is guaranteed, that the combination of symptoms for each patient has a non-zero probability. \OutputFile Print the K strings --- one for each patient. Each line should contain N numbers--- the probability, that a patient has a corresponding disease. Print the probability as floating point number from 0 to 1 with an absolute percentage error not grater than 10 ^7.
Time limit 1 second
Memory limit 256 MiB
Input example #1
1 2
10.00 10.00
40.00 90.00 90.00
3
??
++
+-
Output example #1
0.400000000
0.981818182
0.400000000
Author Евгений Капун
Source Зимняя школа по программированию 2014, Харьков